mirror of
https://github.com/python/cpython.git
synced 2025-08-03 08:34:29 +00:00
(Merge 3.4) asyncio: Fix BaseEventLoop._assert_is_current_event_loop():
get_event_loop() raises an exception if there is no current loop
This commit is contained in:
commit
289cae4f92
1 changed files with 5 additions and 2 deletions
|
@ -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")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue