Skip to content

Commit 738066c

Browse files
committed
Make multiprocessing use compatible with coverage collection
1 parent e66bde9 commit 738066c

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

.coveragerc

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
[run]
2-
source = apt_mirror_updater
2+
branch = true
3+
concurrency = multiprocessing
34
omit = apt_mirror_updater/tests.py
5+
parallel = True
6+
source = apt_mirror_updater

apt_mirror_updater/http.py

+8-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Automated, robust apt-get mirror selection for Debian and Ubuntu.
22
#
33
# Author: Peter Odding <[email protected]>
4-
# Last Change: October 31, 2017
4+
# Last Change: April 15, 2020
55
# URL: https://apt-mirror-updater.readthedocs.io
66

77
"""Simple, robust and concurrent HTTP requests (designed for one very narrow use case)."""
@@ -81,9 +81,14 @@ def fetch_concurrent(urls, concurrency=None):
8181
concurrency = get_default_concurrency()
8282
pool = multiprocessing.Pool(concurrency)
8383
try:
84-
return pool.map(fetch_worker, urls, chunksize=1)
85-
finally:
84+
results = pool.map(fetch_worker, urls, chunksize=1)
85+
pool.close()
86+
pool.join()
87+
return results
88+
except Exception:
8689
pool.terminate()
90+
pool.join()
91+
raise
8792

8893

8994
def get_default_concurrency():

0 commit comments

Comments
 (0)