From 9219b93259584f3bca41ba2daccf702c911c2597 Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Thu, 4 Dec 2014 22:24:08 +0100 Subject: Initialize more Future and Task attributes in the class definition to avoid attribute errors in destructors. --- asyncio/tasks.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'asyncio/tasks.py') diff --git a/asyncio/tasks.py b/asyncio/tasks.py index e073802..698ec6a 100644 --- a/asyncio/tasks.py +++ b/asyncio/tasks.py @@ -41,6 +41,10 @@ class Task(futures.Future): # 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 @@ class Task(futures.Future): 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 -- cgit v1.2.1