sycommon-python-lib 0.2.12a8__py3-none-any.whl → 0.2.12a9__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.
- sycommon/devchat/handler.py +29 -0
- {sycommon_python_lib-0.2.12a8.dist-info → sycommon_python_lib-0.2.12a9.dist-info}/METADATA +1 -1
- {sycommon_python_lib-0.2.12a8.dist-info → sycommon_python_lib-0.2.12a9.dist-info}/RECORD +6 -6
- {sycommon_python_lib-0.2.12a8.dist-info → sycommon_python_lib-0.2.12a9.dist-info}/WHEEL +0 -0
- {sycommon_python_lib-0.2.12a8.dist-info → sycommon_python_lib-0.2.12a9.dist-info}/entry_points.txt +0 -0
- {sycommon_python_lib-0.2.12a8.dist-info → sycommon_python_lib-0.2.12a9.dist-info}/top_level.txt +0 -0
sycommon/devchat/handler.py
CHANGED
|
@@ -210,6 +210,8 @@ class DevchatState:
|
|
|
210
210
|
self._captured_host = ""
|
|
211
211
|
self._fallback_host = ""
|
|
212
212
|
self._fallback_port = 0
|
|
213
|
+
# 优雅退出等待者(wait_idle 注册,release 唤醒;与 Go hub.idleWaiters 对齐)。
|
|
214
|
+
self._idle_waiters: List[asyncio.Future] = []
|
|
213
215
|
|
|
214
216
|
# ---- 宿主地址(与 Go 版 Devchat.serviceBase 同语义) ----
|
|
215
217
|
|
|
@@ -298,6 +300,33 @@ class DevchatState:
|
|
|
298
300
|
def release(self, status: str) -> None:
|
|
299
301
|
self.running = False
|
|
300
302
|
self.last_status = status
|
|
303
|
+
# 优雅退出等待者:任务落地即唤醒(与 Go hub.releaseRunning 同语义)。
|
|
304
|
+
waiters, self._idle_waiters = self._idle_waiters, []
|
|
305
|
+
for fut in waiters:
|
|
306
|
+
if not fut.done():
|
|
307
|
+
fut.set_result(True)
|
|
308
|
+
|
|
309
|
+
async def wait_idle(self, timeout: float) -> bool:
|
|
310
|
+
"""优雅退出等待:在飞任务落地(终态落库/消息回流完)返回 True;
|
|
311
|
+
空闲立即 True;超时返回 False。宿主挂 lifespan/shutdown 钩子用,
|
|
312
|
+
防止换版重启把在飞 claude 任务杀成「服务重启,任务中断」。
|
|
313
|
+
(与 Go Devchat.WaitIdle 对齐。)
|
|
314
|
+
"""
|
|
315
|
+
if not self.running:
|
|
316
|
+
return True
|
|
317
|
+
if timeout <= 0:
|
|
318
|
+
return False
|
|
319
|
+
loop = asyncio.get_running_loop()
|
|
320
|
+
fut: asyncio.Future = loop.create_future()
|
|
321
|
+
self._idle_waiters.append(fut)
|
|
322
|
+
try:
|
|
323
|
+
await asyncio.wait_for(fut, timeout)
|
|
324
|
+
return True
|
|
325
|
+
except asyncio.TimeoutError:
|
|
326
|
+
# 摘除自己(release 时不再触碰已弃用 future)。
|
|
327
|
+
with contextlib.suppress(ValueError):
|
|
328
|
+
self._idle_waiters.remove(fut)
|
|
329
|
+
return False
|
|
301
330
|
|
|
302
331
|
|
|
303
332
|
# _shared_conns 同一 devchat.db 路径 → 唯一连接(任务/消息/事件/会话
|
|
@@ -217,7 +217,7 @@ sycommon/database/txnref.py,sha256=sOFp85PlanCA0oryVpHu53JbM0aSHAVkELWgEJKalLI,7
|
|
|
217
217
|
sycommon/devchat/__init__.py,sha256=Z2BgzDKrp_mR165d3a1kftP8lf1-WKz_5xuZMFXR-iw,2288
|
|
218
218
|
sycommon/devchat/_page.html,sha256=CxzEhC867FawFjlEKk6uCChEX3EoRP4jwdn09C_MdaU,29126
|
|
219
219
|
sycommon/devchat/_page.py,sha256=4y2h9DEJfL07zIKDhdSNEaN1Rpe-yJsKm7H0QnqZC9o,2404
|
|
220
|
-
sycommon/devchat/handler.py,sha256=
|
|
220
|
+
sycommon/devchat/handler.py,sha256=I3zGT0jc0ZqSlB45BcOEnC5lGelD6VUwNLsetnUUMT8,50409
|
|
221
221
|
sycommon/devchat/login.py,sha256=TF57n0iP3jHgiYs4NdDDgAXlGJNtiKcW8haw9Rd9Jjo,7701
|
|
222
222
|
sycommon/devchat/store.py,sha256=iAxCJs5jrNbRDCVL4i0QnbEAUGLXtJumf8YsBGwfBe0,4047
|
|
223
223
|
sycommon/devchat/tasks.py,sha256=ijGHe2gyBfEZ11ylqvRihQDtbF2ugchQ6AzdyNCbD_0,19080
|
|
@@ -404,8 +404,8 @@ sycommon/tools/usercache.py,sha256=Zu2oiXISUOojleEYCAS9t06ZzgWSNHCIhCjv4yTtkRw,4
|
|
|
404
404
|
sycommon/xxljob/__init__.py,sha256=7eoBlQxv-B39IfRSCY2bkqdGYs1QRe1umAWd88VMEEM,86
|
|
405
405
|
sycommon/xxljob/sharding.py,sha256=LJ0tle7qSUS32S5ntjzri1aOcPzwL5CFde3W4Rf1AUE,2560
|
|
406
406
|
sycommon/xxljob/xxljob_service.py,sha256=1yifwIBNGsCIxLnQjHKiBlbsigc_zvPH-dMTZcNxe-Q,7649
|
|
407
|
-
sycommon_python_lib-0.2.
|
|
408
|
-
sycommon_python_lib-0.2.
|
|
409
|
-
sycommon_python_lib-0.2.
|
|
410
|
-
sycommon_python_lib-0.2.
|
|
411
|
-
sycommon_python_lib-0.2.
|
|
407
|
+
sycommon_python_lib-0.2.12a9.dist-info/METADATA,sha256=J_BWty0ohVqabjveYf3OrcNcMnQXTvaaJhwbrjszn3Y,8028
|
|
408
|
+
sycommon_python_lib-0.2.12a9.dist-info/WHEEL,sha256=mOdXR9C3wMVov7cSY8PY-XCzo3SmmWCHvGQr5csJoao,91
|
|
409
|
+
sycommon_python_lib-0.2.12a9.dist-info/entry_points.txt,sha256=gsR4SssKxDWjRU8ggidzNcdMXDPRSKRS7UaGyNP84Qg,92
|
|
410
|
+
sycommon_python_lib-0.2.12a9.dist-info/top_level.txt,sha256=RgphKrg7nJyZ7irJqbxFr-5H2LUYTvI7ivoWZH2hcD0,29
|
|
411
|
+
sycommon_python_lib-0.2.12a9.dist-info/RECORD,,
|
|
File without changes
|
{sycommon_python_lib-0.2.12a8.dist-info → sycommon_python_lib-0.2.12a9.dist-info}/entry_points.txt
RENAMED
|
File without changes
|
{sycommon_python_lib-0.2.12a8.dist-info → sycommon_python_lib-0.2.12a9.dist-info}/top_level.txt
RENAMED
|
File without changes
|