This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author pablogsal
Recipients AMDmi3, arekm, davin, koobs, pablogsal, pitrou
Date 2020-03-15.02:15:13
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1584238513.64.0.613694722076.issue38744@roundup.psfhosted.org>
In-reply-to
Content
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.
History
Date User Action Args
2020-03-15 02:15:13pablogsalsetrecipients: + pablogsal, arekm, pitrou, koobs, davin, AMDmi3
2020-03-15 02:15:13pablogsalsetmessageid: <1584238513.64.0.613694722076.issue38744@roundup.psfhosted.org>
2020-03-15 02:15:13pablogsallinkissue38744 messages
2020-03-15 02:15:13pablogsalcreate