Skip to content
This repository has been archived by the owner on Jan 30, 2023. It is now read-only.

Commit

Permalink
Fix a slight possibility of not aborting until after twice the reques…
Browse files Browse the repository at this point in the history
…ted timeout.

Normally by the time self._results.get() times out the abort timer (self._timer) should have already
fired.  But there's a remote possibility that it hasn't, in which case the existing self._aborted.value
check returns False, and we continue the loop into another self._results.get() call.

Instead just make sure the abort timer has already fired by joining on it--in most cases this will
immediately return.
  • Loading branch information
embray committed Aug 12, 2016
1 parent b6caede commit 2cb9701
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions src/sage/parallel/map_reduce.py
Original file line number Diff line number Diff line change
Expand Up @@ -1134,13 +1134,12 @@ def get_results(self, timeout=None):
(active_proc, timeout, self._aborted.value))
newres = self._results.get(timeout=timeout)
except Empty:
aborted = self._aborted.value
logger.debug('Timed out waiting for results; aborted: %s' %
aborted)
if aborted:
return

continue
logger.debug('Timed out waiting for results; aborting')
# If we timed out here then the abort timer should have
# already fired, but just in case it didn't (or is in
# progress) wait for it to finish
self._timer.join()
return

if newres is not None:
logger.debug("Got one result")
Expand Down

0 comments on commit 2cb9701

Please sign in to comment.