fix(api): always reset job counter when creating new device worker
This commit is contained in:
parent
55e44e8ac9
commit
2b179bebac
|
@ -94,7 +94,9 @@ class DevicePoolExecutor:
|
||||||
# always recreate queues
|
# always recreate queues
|
||||||
self.progress[name] = Queue(self.max_pending_per_worker)
|
self.progress[name] = Queue(self.max_pending_per_worker)
|
||||||
self.pending[name] = Queue(self.max_pending_per_worker)
|
self.pending[name] = Queue(self.max_pending_per_worker)
|
||||||
|
self.total_jobs[device.device] = 0
|
||||||
|
|
||||||
|
# reuse pid sentinel
|
||||||
if name in self.current:
|
if name in self.current:
|
||||||
logger.debug("using existing current worker value")
|
logger.debug("using existing current worker value")
|
||||||
current = self.current[name]
|
current = self.current[name]
|
||||||
|
@ -103,6 +105,7 @@ class DevicePoolExecutor:
|
||||||
current = Value("L", 0)
|
current = Value("L", 0)
|
||||||
self.current[name] = current
|
self.current[name] = current
|
||||||
|
|
||||||
|
# create a new context and worker
|
||||||
context = WorkerContext(
|
context = WorkerContext(
|
||||||
name,
|
name,
|
||||||
device,
|
device,
|
||||||
|
@ -113,15 +116,16 @@ class DevicePoolExecutor:
|
||||||
active_pid=current,
|
active_pid=current,
|
||||||
)
|
)
|
||||||
self.context[name] = context
|
self.context[name] = context
|
||||||
|
|
||||||
worker = Process(
|
worker = Process(
|
||||||
name=f"onnx-web worker: {name}",
|
name=f"onnx-web worker: {name}",
|
||||||
target=worker_main,
|
target=worker_main,
|
||||||
args=(context, self.server),
|
args=(context, self.server),
|
||||||
)
|
)
|
||||||
|
self.workers[name] = worker
|
||||||
|
|
||||||
logger.debug("starting worker for device %s", device)
|
logger.debug("starting worker for device %s", device)
|
||||||
worker.start()
|
worker.start()
|
||||||
self.workers[name] = worker
|
|
||||||
current.value = worker.pid
|
current.value = worker.pid
|
||||||
|
|
||||||
def create_health_worker(self) -> None:
|
def create_health_worker(self) -> None:
|
||||||
|
@ -329,7 +333,6 @@ class DevicePoolExecutor:
|
||||||
for device in self.devices:
|
for device in self.devices:
|
||||||
if device.device in needs_restart:
|
if device.device in needs_restart:
|
||||||
self.create_device_worker(device)
|
self.create_device_worker(device)
|
||||||
self.total_jobs[device.device] = 0
|
|
||||||
|
|
||||||
if self.logger_worker.is_alive():
|
if self.logger_worker.is_alive():
|
||||||
logger.debug("logger worker is running")
|
logger.debug("logger worker is running")
|
||||||
|
|
Loading…
Reference in New Issue