Skip to content

Commit 289cae4

Browse files
committed
(Merge 3.4) asyncio: Fix BaseEventLoop._assert_is_current_event_loop():
get_event_loop() raises an exception if there is no current loop
2 parents ef85df1 + 751c7c0 commit 289cae4

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

Lib/asyncio/base_events.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -332,8 +332,11 @@ def _assert_is_current_event_loop(self):
332332
Should only be called when (self._debug == True). The caller is
333333
responsible for checking this condition for performance reasons.
334334
"""
335-
current = events.get_event_loop()
336-
if current is not None and current is not self:
335+
try:
336+
current = events.get_event_loop()
337+
except AssertionError:
338+
return
339+
if current is not self:
337340
raise RuntimeError(
338341
"non-threadsafe operation invoked on an event loop other "
339342
"than the current one")

0 commit comments

Comments
 (0)