Skip to content

Commit

Permalink
fix hang
Browse files Browse the repository at this point in the history
  • Loading branch information
qinxuye committed Mar 12, 2024
1 parent 1e0225d commit bd2e76f
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions python/xoscar/backends/indigen/pool.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,16 +219,20 @@ def start_pool_in_process():
async def wait_sub_pools_ready(cls, create_pool_tasks: List[asyncio.Task]):
processes: list[multiprocessing.Process] = []
ext_addresses = []
error = None
for task in create_pool_tasks:
process, status = await task
processes.append(process)
if status.status == 1:
# start sub pool failed
# kill previous processes first
for p in processes:
p.terminate()
raise status.error.with_traceback(status.traceback)
processes.append(process)
ext_addresses.append(status.external_addresses)
error = status.error.with_traceback(status.traceback)
else:
ext_addresses.append(status.external_addresses)
if error:
for p in processes:
# error happens, kill all subprocesses
p.kill()
raise error
return processes, ext_addresses

@classmethod
Expand Down

0 comments on commit bd2e76f

Please sign in to comment.