[Python-checkins] cpython (3.4): asyncio: Initialize more Future and Task attributes in the class definition to
victor.stinner
python-checkins at python.org
Thu Dec 4 23:09:42 CET 2014
https://hg.python.org/cpython/rev/4041380e6a2b
changeset: 93721:4041380e6a2b
branch: 3.4
parent: 93719:b099cc290ae9
user: Victor Stinner <victor.stinner at gmail.com>
date: Thu Dec 04 23:00:13 2014 +0100
summary:
asyncio: Initialize more Future and Task attributes in the class definition to
avoid attribute errors in destructors.
files:
Lib/asyncio/futures.py | 3 +--
Lib/asyncio/tasks.py | 7 ++++---
2 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/Lib/asyncio/futures.py b/Lib/asyncio/futures.py
--- a/Lib/asyncio/futures.py
+++ b/Lib/asyncio/futures.py
@@ -135,6 +135,7 @@
_result = None
_exception = None
_loop = None
+ _source_traceback = None
_blocking = False # proper use of future (yield vs yield from)
@@ -155,8 +156,6 @@
self._callbacks = []
if self._loop.get_debug():
self._source_traceback = traceback.extract_stack(sys._getframe(1))
- else:
- self._source_traceback = None
def _format_callbacks(self):
cb = self._callbacks
diff --git a/Lib/asyncio/tasks.py b/Lib/asyncio/tasks.py
--- a/Lib/asyncio/tasks.py
+++ b/Lib/asyncio/tasks.py
@@ -41,6 +41,10 @@
# all running event loops. {EventLoop: Task}
_current_tasks = {}
+ # If False, don't log a message if the task is destroyed whereas its
+ # status is still pending
+ _log_destroy_pending = True
+
@classmethod
def current_task(cls, loop=None):
"""Return the currently running task in an event loop or None.
@@ -73,9 +77,6 @@
self._must_cancel = False
self._loop.call_soon(self._step)
self.__class__._all_tasks.add(self)
- # If False, don't log a message if the task is destroyed whereas its
- # status is still pending
- self._log_destroy_pending = True
# On Python 3.3 or older, objects with a destructor that are part of a
# reference cycle are never destroyed. That's not the case any more on
--
Repository URL: https://hg.python.org/cpython
More information about the Python-checkins
mailing list