You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
frompebbleimportProcessPoolimportconcurrent.futuresimportasyncioimporttimedefblocking_sleep():
foriinrange(2):
print('sleeping for 1 second')
time.sleep(1)
print("finished")
asyncdefmain():
loop=asyncio.get_running_loop()
withProcessPool(max_workers=5) aspool:
tasks= []
tasks.append(loop.run_in_executor(
pool,
blocking_sleep,
None
))
awaitasyncio.gather(*tasks, return_exceptions=False)
importsignalsignal.signal(signal.SIGTERM, signal.default_int_handler) # <---- signal handler installedasyncio.run(main())
with the installed signal handler, the above code crashed with
Process pebble_pool_worker:
Traceback (most recent call last):
File "some/path/lib/python3.11/multiprocessing/process.py", line 314, in _bootstrap
self.run()
File "some/path/lib/python3.11/multiprocessing/process.py", line 108, in run
self._target(*self._args, **self._kwargs)
File "some/path/lib/python3.11/site-packages/pebble/pool/process.py", line 427, in worker_process
for task in worker_get_next_task(channel, params.max_tasks):
File "some/path/lib/python3.11/site-packages/pebble/pool/process.py", line 443, in worker_get_next_task
yield fetch_task(channel)
^^^^^^^^^^^^^^^^^^^
File "some/path/lib/python3.11/site-packages/pebble/pool/process.py", line 455, in fetch_task
while channel.poll():
^^^^^^^^^^^^^^
File "some/path/lib/python3.11/site-packages/pebble/pool/channel.py", line 59, in unix_poll
return bool(poll.poll(timeout))
^^^^^^^^^^^^^^^^^^
KeyboardInterrupt
The concurrent.futures.ProcessPoolExecutor works fine with this setup.
With the following code:
with the installed signal handler, the above code crashed with
The
concurrent.futures.ProcessPoolExecutor
works fine with this setup.Can you please help on this?
The text was updated successfully, but these errors were encountered: