From 05779d911fd1b1caa376120757a72b133c75d884 Mon Sep 17 00:00:00 2001 From: Massimiliano Culpo Date: Tue, 6 Nov 2018 23:26:38 +0100 Subject: 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. --- lib/spack/spack/util/web.py | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) (limited to 'lib') diff --git a/lib/spack/spack/util/web.py b/lib/spack/spack/util/web.py index f04507dae7..b403e44d18 100644 --- a/lib/spack/spack/util/web.py +++ b/lib/spack/spack/util/web.py @@ -60,18 +60,30 @@ class LinkParser(HTMLParser): 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) -- cgit v1.2.3-70-g09d2