Commit d6de5d84 authored by Victor Stinner's avatar Victor Stinner

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."
parent cd95e18b
...@@ -327,7 +327,8 @@ class BaseEventLoop(events.AbstractEventLoop): ...@@ -327,7 +327,8 @@ class BaseEventLoop(events.AbstractEventLoop):
Should only be called when (self._debug == True). The caller is Should only be called when (self._debug == True). The caller is
responsible for checking this condition for performance reasons. responsible for checking this condition for performance reasons.
""" """
if events.get_event_loop() is not self: current = events.get_event_loop()
if current is not None and current is not self:
raise RuntimeError( raise RuntimeError(
"non-threadsafe operation invoked on an event loop other " "non-threadsafe operation invoked on an event loop other "
"than the current one") "than the current one")
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment