summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMassimiliano Culpo <massimiliano.culpo@gmail.com>2018-11-06 23:26:38 +0100
committerTodd Gamblin <tgamblin@llnl.gov>2018-11-06 16:02:37 -0800
commit05779d911fd1b1caa376120757a72b133c75d884 (patch)
treeb5ebf52b145dd9df8f9976a6d923088d22f3ac51
parent4ba3c81bc84a7cacbd3a8d159b22eacc031baca9 (diff)
downloadspack-05779d911fd1b1caa376120757a72b133c75d884.tar.gz
spack-05779d911fd1b1caa376120757a72b133c75d884.tar.bz2
spack-05779d911fd1b1caa376120757a72b133c75d884.tar.xz
spack-05779d911fd1b1caa376120757a72b133c75d884.zip
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.
-rw-r--r--lib/spack/spack/util/web.py26
1 files changed, 19 insertions, 7 deletions
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)