From: Victor Stinner Date: Mon, 23 Jun 2014 13:14:13 +0000 (+0200) Subject: asyncio: Fix BaseEventLoop._assert_is_current_event_loop(): get_event_loop() X-Git-Tag: v3.4.2rc1~334 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=751c7c0f2db30a8a29383ec105d200991c209fe8;p=python asyncio: Fix BaseEventLoop._assert_is_current_event_loop(): get_event_loop() raises an exception if there is no current loop --- diff --git a/Lib/asyncio/base_events.py b/Lib/asyncio/base_events.py index 42d8b0b402..b127142963 100644 --- a/Lib/asyncio/base_events.py +++ b/Lib/asyncio/base_events.py @@ -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")