summaryrefslogtreecommitdiffstats
path: root/Lib/asyncio
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@gmail.com>2014-07-10 20:32:58 (GMT)
committerVictor Stinner <victor.stinner@gmail.com>2014-07-10 20:32:58 (GMT)
commitf68bd88aa61ae6214d3dc5552a7e3f9cf1401507 (patch)
treeb976d878139b73d846ea1498aa867589a7f51b13 /Lib/asyncio
parenteb43214427b1ae6d7095bdd2333e9bc2220f9449 (diff)
downloadcpython-f68bd88aa61ae6214d3dc5552a7e3f9cf1401507.zip
cpython-f68bd88aa61ae6214d3dc5552a7e3f9cf1401507.tar.gz
cpython-f68bd88aa61ae6214d3dc5552a7e3f9cf1401507.tar.bz2
asyncio: sync with Tulip
- Issues #21936, #21163: Fix sporadic failures of test_future_exception_never_retrieved() - Handle.cancel() now clears references to callback and args - In debug mode, repr(Handle) now contains the location where the Handle was created.
Diffstat (limited to 'Lib/asyncio')
-rw-r--r--Lib/asyncio/events.py18
1 files changed, 14 insertions, 4 deletions
diff --git a/Lib/asyncio/events.py b/Lib/asyncio/events.py
index 1f5e582..bddd7e3 100644
--- a/Lib/asyncio/events.py
+++ b/Lib/asyncio/events.py
@@ -82,14 +82,20 @@ class Handle:
self._source_traceback = None
def __repr__(self):
- info = []
+ info = [self.__class__.__name__]
if self._cancelled:
info.append('cancelled')
- info.append(_format_callback(self._callback, self._args))
- return '<%s %s>' % (self.__class__.__name__, ' '.join(info))
+ if self._callback is not None:
+ info.append(_format_callback(self._callback, self._args))
+ if self._source_traceback:
+ frame = self._source_traceback[-1]
+ info.append('created at %s:%s' % (frame[0], frame[1]))
+ return '<%s>' % ' '.join(info)
def cancel(self):
self._cancelled = True
+ self._callback = None
+ self._args = None
def _run(self):
try:
@@ -125,7 +131,11 @@ class TimerHandle(Handle):
if self._cancelled:
info.append('cancelled')
info.append('when=%s' % self._when)
- info.append(_format_callback(self._callback, self._args))
+ if self._callback is not None:
+ info.append(_format_callback(self._callback, self._args))
+ if self._source_traceback:
+ frame = self._source_traceback[-1]
+ info.append('created at %s:%s' % (frame[0], frame[1]))
return '<%s %s>' % (self.__class__.__name__, ' '.join(info))
def __hash__(self):