1
0
Fork 0

fix(api): prevent workers from blocking on their progress queues

This commit is contained in:
Sean Sube 2023-03-05 20:07:06 -06:00
parent edc55ae8b4
commit 3a4928e59b
Signed by: ssube
GPG Key ID: 3EED7B957D362AF1
2 changed files with 5 additions and 1 deletions

View File

@ -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,

View File

@ -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)