diff options
author | Victor Stinner <victor.stinner@gmail.com> | 2015-01-30 00:04:27 +0100 |
---|---|---|
committer | Victor Stinner <victor.stinner@gmail.com> | 2015-01-30 00:04:27 +0100 |
commit | 2647375cc98ac47dffdf495fc4b0fe5973b0375d (patch) | |
tree | df9bf8676f542e148b28c8950a3ee2cab0f1cc0b /Lib/asyncio/base_events.py | |
parent | 29b40c1569e96182ba677f7d31bce45695913105 (diff) | |
parent | 978a9afc6af6c137065bdcf7ae4ef5450e5b2ec2 (diff) | |
download | cpython-git-2647375cc98ac47dffdf495fc4b0fe5973b0375d.tar.gz |
Merge 3.4 (asyncio)
Diffstat (limited to 'Lib/asyncio/base_events.py')
-rw-r--r-- | Lib/asyncio/base_events.py | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/Lib/asyncio/base_events.py b/Lib/asyncio/base_events.py index e40d3ad5f2..7108f2516a 100644 --- a/Lib/asyncio/base_events.py +++ b/Lib/asyncio/base_events.py @@ -26,6 +26,7 @@ import threading import time import traceback import sys +import warnings from . import coroutines from . import events @@ -333,6 +334,16 @@ class BaseEventLoop(events.AbstractEventLoop): """Returns True if the event loop was closed.""" return self._closed + # On Python 3.3 and older, objects with a destructor part of a reference + # cycle are never destroyed. It's not more the case on Python 3.4 thanks + # to the PEP 442. + if sys.version_info >= (3, 4): + def __del__(self): + if not self.is_closed(): + warnings.warn("unclosed event loop %r" % self, ResourceWarning) + if not self.is_running(): + self.close() + def is_running(self): """Returns True if the event loop is running.""" return (self._owner is not None) |