summaryrefslogtreecommitdiffstats
path: root/Lib/concurrent/futures
diff options
context:
space:
mode:
authorSam Martin <ABitMoreDepth@users.noreply.github.com>2019-05-22 21:29:02 (GMT)
committerAntoine Pitrou <antoine@python.org>2019-05-22 21:29:02 (GMT)
commit2a3a2ece502c05ea33c95dd0db497189e0354bfd (patch)
tree76436af78c3c003166a1e4c353feb03c67314928 /Lib/concurrent/futures
parentd8a82e2897b735e2b7e9e086f1d709365a2ad72c (diff)
downloadcpython-2a3a2ece502c05ea33c95dd0db497189e0354bfd.zip
cpython-2a3a2ece502c05ea33c95dd0db497189e0354bfd.tar.gz
cpython-2a3a2ece502c05ea33c95dd0db497189e0354bfd.tar.bz2
bpo-33110: Catch errors raised when running add_done_callback on already completed futures (GH-13141)
Wrap the callback call within the `add_done_callback` function within concurrent.futures, in order to behave in an identical manner to callbacks added to a running future are triggered once it has completed.
Diffstat (limited to 'Lib/concurrent/futures')
-rw-r--r--Lib/concurrent/futures/_base.py5
1 files changed, 4 insertions, 1 deletions
diff --git a/Lib/concurrent/futures/_base.py b/Lib/concurrent/futures/_base.py
index 8f155f0..6001e3b 100644
--- a/Lib/concurrent/futures/_base.py
+++ b/Lib/concurrent/futures/_base.py
@@ -404,7 +404,10 @@ class Future(object):
if self._state not in [CANCELLED, CANCELLED_AND_NOTIFIED, FINISHED]:
self._done_callbacks.append(fn)
return
- fn(self)
+ try:
+ fn(self)
+ except Exception:
+ LOGGER.exception('exception calling callback for %r', self)
def result(self, timeout=None):
"""Return the result of the call that the future represents.