fix(api): prevent workers from blocking on their progress queues
This commit is contained in:
parent
edc55ae8b4
commit
3a4928e59b
|
@ -15,7 +15,7 @@ class WorkerContext:
|
||||||
cancel: "Value[bool]"
|
cancel: "Value[bool]"
|
||||||
job: str
|
job: str
|
||||||
pending: "Queue[Tuple[str, Callable[..., None], Any, Any]]"
|
pending: "Queue[Tuple[str, Callable[..., None], Any, Any]]"
|
||||||
progress: "Value[int]"
|
progress: "Queue[Tuple[str, str, int]]"
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
|
|
|
@ -18,6 +18,10 @@ def worker_main(context: WorkerContext, server: ServerContext):
|
||||||
|
|
||||||
logger.info("checking in from worker, %s", get_available_providers())
|
logger.info("checking in from worker, %s", get_available_providers())
|
||||||
|
|
||||||
|
# make leaking workers easier to recycle
|
||||||
|
context.progress.cancel_join_thread()
|
||||||
|
context.finished.cancel_join_thread()
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
try:
|
try:
|
||||||
name, fn, args, kwargs = context.pending.get(timeout=1.0)
|
name, fn, args, kwargs = context.pending.get(timeout=1.0)
|
||||||
|
|
Loading…
Reference in New Issue