Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 33d2e40

Browse files
committed
(Merge 3.4) asyncio: BaseEventLoop._assert_is_current_event_loop() now only
raises an exception if the current loop is not None. Guido van Rossum wrote: "The behavior that you can set the loop to None (and keep track of it explicitly) is part of the spec, and this should still be supported even in debug mode. The behavior that we raise an error if you are caught having multiple active loops per thread is just a debugging heuristic, and it shouldn't break code that follows the spec."
2 parents 2a1a490 + d6de5d8 commit 33d2e40

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

Lib/asyncio/base_events.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,8 @@ def _assert_is_current_event_loop(self):
327327
Should only be called when (self._debug == True). The caller is
328328
responsible for checking this condition for performance reasons.
329329
"""
330-
if events.get_event_loop() is not self:
330+
current = events.get_event_loop()
331+
if current is not None and current is not self:
331332
raise RuntimeError(
332333
"non-threadsafe operation invoked on an event loop other "
333334
"than the current one")

0 commit comments

Comments
 (0)