[Python-checkins] cpython (merge 3.4 -> default): (Merge 3.4) asyncio: Fix BaseEventLoop._assert_is_current_event_loop():

victor.stinner python-checkins at python.org
Mon Jun 23 15:15:45 CEST 2014


http://hg.python.org/cpython/rev/3fffe9681f60
changeset:   91347:3fffe9681f60
parent:      91344:8e3ef955dbc3
parent:      91346:389ef84c2823
user:        Victor Stinner <victor.stinner at gmail.com>
date:        Mon Jun 23 15:14:50 2014 +0200
summary:
  (Merge 3.4) asyncio: Fix BaseEventLoop._assert_is_current_event_loop():
get_event_loop() raises an exception if there is no current loop

files:
  Lib/asyncio/base_events.py |  7 +++++--
  1 files changed, 5 insertions(+), 2 deletions(-)


diff --git a/Lib/asyncio/base_events.py b/Lib/asyncio/base_events.py
--- a/Lib/asyncio/base_events.py
+++ b/Lib/asyncio/base_events.py
@@ -332,8 +332,11 @@
         Should only be called when (self._debug == True). The caller is
         responsible for checking this condition for performance reasons.
         """
-        current = events.get_event_loop()
-        if current is not None and current is not self:
+        try:
+            current = events.get_event_loop()
+        except AssertionError:
+            return
+        if current is not self:
             raise RuntimeError(
                 "non-threadsafe operation invoked on an event loop other "
                 "than the current one")

-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list