Message364211
I am mentoring @BTaskaya and I asked to take a look a this. After some debugging, we found that the problem is the following:
When the pull is not used via the context manager or terminate() is called, there is a system in multiprocessing.util that handles finalization of all pools via an atexit handler (the Finalize) class. This class registers the _terminate_pool handler in the registry of finalizers of the module, and that registry is called on interpreter exit via _exit_function.
The problem is that the "happy" path with the context manager or manual call to finalize() does some extra steps that _terminate_pool does not:
def terminate(self):
util.debug('terminating pool')
self._state = TERMINATE
self._worker_handler._state = TERMINATE
self._change_notifier.put(None)
self._terminate()
In this code self._terminate() calls _terminate_pool. The step that is not executed when the atexit() handler calls _terminate_pool is pinging the _change_notifier queue to unblock the maintenance threads.
The fix is moving the "self._change_notifier.put(None)" to the _terminate_pool function. |
|
Date |
User |
Action |
Args |
2020-03-15 02:15:13 | pablogsal | set | recipients:
+ pablogsal, arekm, pitrou, koobs, davin, AMDmi3 |
2020-03-15 02:15:13 | pablogsal | set | messageid: <1584238513.64.0.613694722076.issue38744@roundup.psfhosted.org> |
2020-03-15 02:15:13 | pablogsal | link | issue38744 messages |
2020-03-15 02:15:13 | pablogsal | create | |
|