Skip to content

Make sure that backend testing in multiprocessing is done with a timeout #3741

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Nov 1, 2014
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 41 additions & 11 deletions setupext.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
import warnings
from textwrap import fill


PY3 = (sys.version_info[0] >= 3)


Expand Down Expand Up @@ -1788,16 +1787,26 @@ def check_requirements(self):
except:
return "unknown (can not use multiprocessing to determine)"
try:
success, msg = p.map(backend_gtk3agg_internal_check, [0])[0]
res = p.map_async(backend_gtk3agg_internal_check, [0])
success, msg = res.get(timeout=10)[0]
except multiprocessing.TimeoutError:
p.terminate()
# No result returned. Probaly hanging, terminate the process.
success = False
raise CheckFailed("Check timed out")
except:
p.close()
# Some other error.
success = False
msg = "Could not determine"
finally:
raise
else:
p.close()
finally:
p.join()

if success:
BackendAgg.force = True

return msg
else:
raise CheckFailed(msg)
Expand Down Expand Up @@ -1852,12 +1861,25 @@ def check_requirements(self):
p = multiprocessing.Pool()
except:
return "unknown (can not use multiprocessing to determine)"
success, msg = p.map(backend_gtk3cairo_internal_check, [0])[0]
p.close()
p.join()
try:
res = p.map_async(backend_gtk3cairo_internal_check, [0])
success, msg = res.get(timeout=10)[0]
except multiprocessing.TimeoutError:
p.terminate()
# No result returned. Probaly hanging, terminate the process.
success = False
raise CheckFailed("Check timed out")
except:
p.close()
success = False
raise
else:
p.close()
finally:
p.join()

if success:
BackendAgg.force = True

return msg
else:
raise CheckFailed(msg)
Expand Down Expand Up @@ -1988,13 +2010,21 @@ def check_requirements(self):
else:
# Multiprocessing OK
try:
msg = p.map(self.callback, [self])[0]
res = p.map_async(self.callback, [self])
msg = res.get(timeout=10)[0]
except multiprocessing.TimeoutError:
p.terminate()
# No result returned. Probaly hanging, terminate the process.
raise CheckFailed("Check timed out")
except:
# If we hit an error on multiprocessing raise it
# Some other error.
p.close()
raise
else:
# Clean exit
p.close()
finally:
# Tidy up multiprocessing
p.close()
p.join()

return msg
Expand Down