]> granicus.if.org Git - python/commitdiff
asyncio: Fix BaseEventLoop._assert_is_current_event_loop(): get_event_loop()
authorVictor Stinner <victor.stinner@gmail.com>
Mon, 23 Jun 2014 13:14:13 +0000 (15:14 +0200)
committerVictor Stinner <victor.stinner@gmail.com>
Mon, 23 Jun 2014 13:14:13 +0000 (15:14 +0200)
raises an exception if there is no current loop

Lib/asyncio/base_events.py

index 42d8b0b4027cda4d6a49fa3d4a8cd0a4af3b94d4..b1271429637d042c953840e4883fe4ddc4c87951 100644 (file)
@@ -332,8 +332,11 @@ class BaseEventLoop(events.AbstractEventLoop):
         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")