[sleep functionality] code refactor about sleep/wake_up (#50431)

Signed-off-by: Andy Xie <andy.xning@gmail.com>
This commit is contained in:
Ning Xie
2026-08-25 07:45:20 +00:00
committed by GitHub
parent 5e379a361e
commit 23310bc3de
3 changed files with 4 additions and 7 deletions
+3 -3
View File
@@ -15,7 +15,7 @@ from functools import partial
from inspect import isclass, signature
from logging import DEBUG
from multiprocessing.queues import Queue
from typing import Any, TypeVar, cast
from typing import Any, TypeVar, cast, get_args
import msgspec
import zmq
@@ -855,7 +855,7 @@ class EngineCore:
- ``keep``: Set PAUSED_ALL; return a Future that completes when the
output queue is empty.
"""
if mode not in ("keep", "abort", "wait"):
if mode not in get_args(PauseMode):
raise ValueError(f"Invalid pause mode: {mode}")
if mode == "wait":
raise ValueError("'wait' mode can't be used in inproc-engine mode")
@@ -1933,7 +1933,7 @@ class EngineCoreProc(EngineCore):
- ``keep``: Set PAUSED_ALL; return a Future that completes when the
output queue is empty.
"""
if mode not in ("keep", "abort", "wait"):
if mode not in get_args(PauseMode):
raise ValueError(f"Invalid pause mode: {mode}")
def engine_idle_callback(engine: "EngineCoreProc", future: Future[Any]) -> None: