Skip to content

Commit

Permalink
fix(api): prevent workers from blocking on their progress queues
Browse files Browse the repository at this point in the history
  • Loading branch information
ssube committed Mar 6, 2023
1 parent edc55ae commit 3a4928e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion api/onnx_web/worker/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class WorkerContext:
cancel: "Value[bool]"
job: str
pending: "Queue[Tuple[str, Callable[..., None], Any, Any]]"
progress: "Value[int]"
progress: "Queue[Tuple[str, str, int]]"

def __init__(
self,
Expand Down
4 changes: 4 additions & 0 deletions api/onnx_web/worker/worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ def worker_main(context: WorkerContext, server: ServerContext):

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:
try:
name, fn, args, kwargs = context.pending.get(timeout=1.0)
Expand Down

0 comments on commit 3a4928e

Please sign in to comment.