index: Make sure that pool is safely closed and joined.
Make sure we call close and join methods of Pool object properly in any case. This fixes hundreds of processes appeard in buildfarm.
This commit is contained in:
+14
-5
@@ -113,16 +113,19 @@ class Index(xmlfile.XmlFile):
|
||||
# have
|
||||
pool = multiprocessing.Pool()
|
||||
|
||||
# Before calling pool.map check if list is empty or not: python#12157
|
||||
if specs:
|
||||
try:
|
||||
# Add source packages to index using a process pool
|
||||
self.specs = pool.map(add_spec, specs)
|
||||
except:
|
||||
# If an exception occurs (like a keyboard interrupt), immediately
|
||||
# terminate worker processes and propagate exception. (CLI honors
|
||||
# KeyboardInterrupt exception, if you're not using CLI, you must
|
||||
# handle KeyboardException yourself)
|
||||
# If an exception occurs (like a keyboard interrupt),
|
||||
# immediately terminate worker processes and propagate
|
||||
# exception. (CLI honors KeyboardInterrupt exception, if you're
|
||||
# not using CLI, you must handle KeyboardException yourself)
|
||||
|
||||
pool.terminate()
|
||||
pool.join()
|
||||
raise
|
||||
|
||||
try:
|
||||
@@ -144,13 +147,19 @@ class Index(xmlfile.XmlFile):
|
||||
|
||||
latest_packages.append((pkg, deltas, repo_uri))
|
||||
|
||||
# Before calling pool.map check if list is empty or not: python#12157
|
||||
if latest_packages:
|
||||
try:
|
||||
# Add binary packages to index using a process pool
|
||||
self.packages = pool.map(add_package, latest_packages)
|
||||
except:
|
||||
pool.terminate()
|
||||
pool.join()
|
||||
raise
|
||||
else:
|
||||
|
||||
pool.close()
|
||||
pool.join()
|
||||
|
||||
# Clean up output
|
||||
ctx.ui.info("\r%-80.80s" % (_('Done.')))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user