Adapted the code of the non-daemonic pool to recent python versions

fixes #9739

The non-daemonic pool relies heavily on implementation details of the
multiprocessing package. In this commit we provide an implementation
that fits recent python versions.
This commit is contained in:
Massimiliano Culpo 2018-11-06 23:26:38 +01:00 committed by Todd Gamblin
parent 4ba3c81bc8
commit 05779d911f

View File

@ -60,18 +60,30 @@ def handle_starttag(self, tag, attrs):
class NonDaemonProcess(multiprocessing.Process):
"""Process tha allows sub-processes, so pools can have sub-pools."""
def _get_daemon(self):
@property
def daemon(self):
return False
def _set_daemon(self, value):
@daemon.setter
def daemon(self, value):
pass
daemon = property(_get_daemon, _set_daemon)
if sys.version_info[0] < 3:
class NonDaemonPool(multiprocessing.pool.Pool):
"""Pool that uses non-daemon processes"""
Process = NonDaemonProcess
else:
class NonDaemonPool(multiprocessing.pool.Pool):
"""Pool that uses non-daemon processes"""
Process = NonDaemonProcess
class NonDaemonContext(type(multiprocessing.get_context())):
Process = NonDaemonProcess
class NonDaemonPool(multiprocessing.pool.Pool):
"""Pool that uses non-daemon processes"""
def __init__(self, *args, **kwargs):
kwargs['context'] = NonDaemonContext()
super(NonDaemonPool, self).__init__(*args, **kwargs)
def _spider(url, visited, root, depth, max_depth, raise_on_error):
@ -310,7 +322,7 @@ def find_versions_of_archive(archive_urls, list_url=None, list_depth=0):
# .sha256
# .sig
# However, SourceForge downloads still need to end in '/download'.
url_regex += '(\/download)?$'
url_regex += r'(\/download)?$'
regexes.append(url_regex)