Skip to content

Commit

Permalink
fix(api): watch for progress events from leaking workers
Browse files Browse the repository at this point in the history
  • Loading branch information
ssube committed Mar 26, 2023
1 parent e1219cc commit 4ddd69b
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion api/onnx_web/worker/pool.py
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ def join(self):

def join_leaking(self):
if len(self.leaking) > 0:
for device, worker, _context in self.leaking:
for device, worker, context in self.leaking:
logger.warning(
"shutting down leaking worker %s for device %s", worker.pid, device
)
Expand All @@ -289,6 +289,21 @@ def join_leaking(self):
device,
)

try:
progress = context.progress.get_nowait()
while progress is not None:
self.update_job(progress)
progress = context.progress.get_nowait()
except Empty:
logger.trace("empty queue in leaking worker for device %s", device)
except ValueError as e:
logger.debug("value error in leaking worker for device %s: %s", device, e)
break
except Exception:
logger.exception("error in leaking worker for device %s", device)



self.leaking[:] = [dw for dw in self.leaking if dw[1].is_alive()]

def recycle(self):
Expand Down

0 comments on commit 4ddd69b

Please sign in to comment.