pycoze 0.1.338__py3-none-any.whl → 0.1.340__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- pycoze/reference/__init__.py +4 -0
- pycoze/reference/lib.py +16 -6
- {pycoze-0.1.338.dist-info → pycoze-0.1.340.dist-info}/METADATA +7 -9
- {pycoze-0.1.338.dist-info → pycoze-0.1.340.dist-info}/RECORD +7 -7
- {pycoze-0.1.338.dist-info → pycoze-0.1.340.dist-info}/WHEEL +1 -1
- {pycoze-0.1.338.dist-info → pycoze-0.1.340.dist-info}/LICENSE +0 -0
- {pycoze-0.1.338.dist-info → pycoze-0.1.340.dist-info}/top_level.txt +0 -0
pycoze/reference/__init__.py
CHANGED
pycoze/reference/lib.py
CHANGED
@@ -6,7 +6,6 @@ import inspect
|
|
6
6
|
import asyncio
|
7
7
|
import nest_asyncio
|
8
8
|
|
9
|
-
# 应用 nest_asyncio 补丁,以允许在已经运行的事件循环中再次运行事件循环
|
10
9
|
nest_asyncio.apply()
|
11
10
|
|
12
11
|
def call_func(func, args=None, kwargs=None):
|
@@ -17,19 +16,30 @@ def call_func(func, args=None, kwargs=None):
|
|
17
16
|
|
18
17
|
if inspect.isgeneratorfunction(func):
|
19
18
|
return list(func(*args, **kwargs))
|
19
|
+
elif inspect.isasyncgenfunction(func):
|
20
|
+
async def collect_async_gen():
|
21
|
+
return [item async for item in func(*args, **kwargs)]
|
22
|
+
|
23
|
+
try:
|
24
|
+
loop = asyncio.get_running_loop()
|
25
|
+
except RuntimeError:
|
26
|
+
return asyncio.run(collect_async_gen())
|
27
|
+
else:
|
28
|
+
async def run_async_gen():
|
29
|
+
return await collect_async_gen()
|
30
|
+
future = asyncio.ensure_future(run_async_gen())
|
31
|
+
while not future.done():
|
32
|
+
loop.run_until_complete(asyncio.sleep(0.1)) # 避免阻塞
|
33
|
+
return future.result()
|
20
34
|
elif inspect.iscoroutinefunction(func):
|
21
35
|
coro = func(*args, **kwargs) if inspect.iscoroutinefunction(func) else func
|
22
36
|
try:
|
23
|
-
# 尝试获取当前运行的事件循环
|
24
37
|
loop = asyncio.get_running_loop()
|
25
38
|
except RuntimeError:
|
26
|
-
# 如果没有运行的事件循环,使用 asyncio.run()
|
27
39
|
return asyncio.run(coro)
|
28
40
|
else:
|
29
|
-
# 如果事件循环已经在运行,直接调度协程并等待结果
|
30
41
|
async def run_coro():
|
31
42
|
return await coro
|
32
|
-
# 在当前事件循环中调度任务并等待完成
|
33
43
|
future = asyncio.ensure_future(run_coro())
|
34
44
|
while not future.done():
|
35
45
|
loop.run_until_complete(asyncio.sleep(0.1)) # 避免阻塞
|
@@ -96,7 +106,7 @@ def wrapped_func(func, module_path):
|
|
96
106
|
print(f"调用 {func.__name__} 时发生错误: {str(e)}")
|
97
107
|
raise
|
98
108
|
|
99
|
-
print(f"{func.__name__}
|
109
|
+
print(f"{func.__name__} 调用完毕")
|
100
110
|
|
101
111
|
return result
|
102
112
|
|
@@ -1,22 +1,18 @@
|
|
1
|
-
Metadata-Version: 2.
|
1
|
+
Metadata-Version: 2.1
|
2
2
|
Name: pycoze
|
3
|
-
Version: 0.1.
|
3
|
+
Version: 0.1.340
|
4
4
|
Summary: Package for pycoze only!
|
5
|
+
Home-page: UNKNOWN
|
5
6
|
Author: Yuan Jie Xiong
|
6
7
|
Author-email: aiqqqqqqq@qq.com
|
8
|
+
License: UNKNOWN
|
9
|
+
Platform: UNKNOWN
|
7
10
|
Classifier: Programming Language :: Python :: 3
|
8
11
|
Classifier: License :: OSI Approved :: MIT License
|
9
12
|
Classifier: Operating System :: OS Independent
|
10
13
|
Requires-Python: >=3.6
|
11
14
|
Description-Content-Type: text/markdown
|
12
15
|
License-File: LICENSE
|
13
|
-
Dynamic: author
|
14
|
-
Dynamic: author-email
|
15
|
-
Dynamic: classifier
|
16
|
-
Dynamic: description
|
17
|
-
Dynamic: description-content-type
|
18
|
-
Dynamic: requires-python
|
19
|
-
Dynamic: summary
|
20
16
|
|
21
17
|
# PYCOZE
|
22
18
|
|
@@ -32,3 +28,5 @@ Package for pycoze only!
|
|
32
28
|
<!-- python setup.py sdist bdist_wheel -->
|
33
29
|
<!-- twine upload dist/* -->
|
34
30
|
<!-- 修改src\renderer\layout\init\const.ts中的库版本要求 -->
|
31
|
+
|
32
|
+
|
@@ -18,9 +18,9 @@ pycoze/bot/lib.py,sha256=smigeWuhl8esHE-Y5l_9bpjJkEJ5OqrxTyPcO8JIubM,7224
|
|
18
18
|
pycoze/bot/message.py,sha256=Zq-_k8HztBMOUIs3hbOvWvwHBNopn4UJJBliCROIGcc,718
|
19
19
|
pycoze/bot/prompt.md,sha256=OBxwUY6yiwEmusnUHhwixWYByrWX3BpwfxG_Gfas8UM,15783
|
20
20
|
pycoze/bot/tools.py,sha256=23iDk0_myJcQDOErKm4LRGr1Foane1n_RNNKJPAmgdY,9953
|
21
|
-
pycoze/reference/__init__.py,sha256=
|
21
|
+
pycoze/reference/__init__.py,sha256=zgqGqvmA9HaqytEM33B6vi0kQVk8IiCwJaXa22xsFz8,114
|
22
22
|
pycoze/reference/bot.py,sha256=pxHVYo0G3P3YZ--vBYbMEiEyBoxxPwaO5dMTf9WFMSc,2014
|
23
|
-
pycoze/reference/lib.py,sha256=
|
23
|
+
pycoze/reference/lib.py,sha256=T-oBOKxkus5dTouc0oDgfRzUyi6aTyY-FF4yX7SzF5M,3755
|
24
24
|
pycoze/reference/tool.py,sha256=h7G3KSoZYWq5IJu6E0-shIQ3XiJeJsgSM85GxEnhF98,1107
|
25
25
|
pycoze/reference/workflow.py,sha256=whQtw_FAxvlSbjow1oNFLdytPjjRs_pDBbQmNjaX6zc,1340
|
26
26
|
pycoze/ui/__init__.py,sha256=uaXet23wUk64TcZjpBX8qOx4aUhwA_ucrmcxy7Q4Qr4,929
|
@@ -33,8 +33,8 @@ pycoze/utils/arg.py,sha256=jop1tBfe5hYkHW1NSpCeaZBEznkgguBscj_7M2dWfrs,503
|
|
33
33
|
pycoze/utils/env.py,sha256=5pWlXfM1F5ZU9hhv1rHlDEanjEW5wf0nbyez9bNRqqA,559
|
34
34
|
pycoze/utils/socket.py,sha256=bZbFFRH4mfThzRqt55BAAGQ6eICx_ja4x8UGGrUdAm8,2428
|
35
35
|
pycoze/utils/text_or_file.py,sha256=gpxZVWt2DW6YiEg_MnMuwg36VNf3TX383QD_1oZNB0Y,551
|
36
|
-
pycoze-0.1.
|
37
|
-
pycoze-0.1.
|
38
|
-
pycoze-0.1.
|
39
|
-
pycoze-0.1.
|
40
|
-
pycoze-0.1.
|
36
|
+
pycoze-0.1.340.dist-info/LICENSE,sha256=QStd_Qsd0-kAam_-sOesCIp_uKrGWeoKwt9M49NVkNU,1090
|
37
|
+
pycoze-0.1.340.dist-info/METADATA,sha256=kLgmkro5V7i3b8aqOjUUmVG0moAiUX8TVKcp3r_OXIU,755
|
38
|
+
pycoze-0.1.340.dist-info/WHEEL,sha256=ewwEueio1C2XeHTvT17n8dZUJgOvyCWCt0WVNLClP9o,92
|
39
|
+
pycoze-0.1.340.dist-info/top_level.txt,sha256=76dPeDhKvOCleL3ZC5gl1-y4vdS1tT_U1hxWVAn7sFo,7
|
40
|
+
pycoze-0.1.340.dist-info/RECORD,,
|
File without changes
|
File without changes
|