pycoze 0.1.326__py3-none-any.whl → 0.1.328__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/lib.py +6 -11
- {pycoze-0.1.326.dist-info → pycoze-0.1.328.dist-info}/METADATA +1 -1
- {pycoze-0.1.326.dist-info → pycoze-0.1.328.dist-info}/RECORD +6 -6
- {pycoze-0.1.326.dist-info → pycoze-0.1.328.dist-info}/LICENSE +0 -0
- {pycoze-0.1.326.dist-info → pycoze-0.1.328.dist-info}/WHEEL +0 -0
- {pycoze-0.1.326.dist-info → pycoze-0.1.328.dist-info}/top_level.txt +0 -0
pycoze/reference/lib.py
CHANGED
@@ -5,12 +5,6 @@ import functools
|
|
5
5
|
import inspect
|
6
6
|
import asyncio
|
7
7
|
|
8
|
-
import inspect
|
9
|
-
import asyncio
|
10
|
-
|
11
|
-
import inspect
|
12
|
-
import asyncio
|
13
|
-
|
14
8
|
def call_func(func, args=None, kwargs=None):
|
15
9
|
if args is None:
|
16
10
|
args = ()
|
@@ -20,9 +14,7 @@ def call_func(func, args=None, kwargs=None):
|
|
20
14
|
if inspect.isgeneratorfunction(func):
|
21
15
|
return list(func(*args, **kwargs))
|
22
16
|
elif inspect.iscoroutinefunction(func):
|
23
|
-
# 确保 func 是协程函数,而不是协程对象
|
24
17
|
coro = func(*args, **kwargs) if inspect.iscoroutinefunction(func) else func
|
25
|
-
|
26
18
|
try:
|
27
19
|
# 尝试获取当前运行的事件循环
|
28
20
|
loop = asyncio.get_running_loop()
|
@@ -30,11 +22,14 @@ def call_func(func, args=None, kwargs=None):
|
|
30
22
|
# 如果没有运行的事件循环,使用 asyncio.run()
|
31
23
|
return asyncio.run(coro)
|
32
24
|
else:
|
33
|
-
#
|
25
|
+
# 如果事件循环已经在运行,直接调度协程并等待结果
|
34
26
|
async def run_coro():
|
35
27
|
return await coro
|
36
|
-
#
|
37
|
-
|
28
|
+
# 在当前事件循环中调度任务并等待完成
|
29
|
+
future = asyncio.ensure_future(run_coro())
|
30
|
+
while not future.done():
|
31
|
+
loop.run_until_complete(asyncio.sleep(0.1)) # 避免阻塞
|
32
|
+
return future.result()
|
38
33
|
else:
|
39
34
|
return func(*args, **kwargs)
|
40
35
|
|
@@ -20,7 +20,7 @@ pycoze/bot/prompt.md,sha256=ehjdvZ-se9NaH0OSiDEvrFE9kvdj9MTZlWZUTxPY780,15743
|
|
20
20
|
pycoze/bot/tools.py,sha256=HqfBaJjS9Jg9-MGObD5Iegs8NZsM63DIPbaoMRZR5ms,9737
|
21
21
|
pycoze/reference/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
22
22
|
pycoze/reference/bot.py,sha256=pxHVYo0G3P3YZ--vBYbMEiEyBoxxPwaO5dMTf9WFMSc,2014
|
23
|
-
pycoze/reference/lib.py,sha256=
|
23
|
+
pycoze/reference/lib.py,sha256=cM0bdASF8OrajPoMtJtJQRYxbWDOGk1jQETYnXSbS6w,3385
|
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.328.dist-info/LICENSE,sha256=QStd_Qsd0-kAam_-sOesCIp_uKrGWeoKwt9M49NVkNU,1090
|
37
|
+
pycoze-0.1.328.dist-info/METADATA,sha256=2e_TbG-DHro5EPTNv_bRUG_waPdLRyPCdlnY_zWTpf4,854
|
38
|
+
pycoze-0.1.328.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
|
39
|
+
pycoze-0.1.328.dist-info/top_level.txt,sha256=76dPeDhKvOCleL3ZC5gl1-y4vdS1tT_U1hxWVAn7sFo,7
|
40
|
+
pycoze-0.1.328.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|