mirror of
https://github.com/python/cpython.git
synced 2025-08-03 16:39:00 +00:00
Issue #23074: asyncio.get_event_loop() now raises an exception if the thread
has no event loop even if assertions are disabled.
This commit is contained in:
parent
2338156fa4
commit
3a1c738e6c
3 changed files with 6 additions and 6 deletions
|
@ -420,7 +420,7 @@ class BaseEventLoop(events.AbstractEventLoop):
|
|||
"""
|
||||
try:
|
||||
current = events.get_event_loop()
|
||||
except AssertionError:
|
||||
except RuntimeError:
|
||||
return
|
||||
if current is not self:
|
||||
raise RuntimeError(
|
||||
|
|
|
@ -517,9 +517,9 @@ class BaseDefaultEventLoopPolicy(AbstractEventLoopPolicy):
|
|||
not self._local._set_called and
|
||||
isinstance(threading.current_thread(), threading._MainThread)):
|
||||
self.set_event_loop(self.new_event_loop())
|
||||
assert self._local._loop is not None, \
|
||||
('There is no current event loop in thread %r.' %
|
||||
threading.current_thread().name)
|
||||
if self._local._loop is None:
|
||||
raise RuntimeError('There is no current event loop in thread %r.'
|
||||
% threading.current_thread().name)
|
||||
return self._local._loop
|
||||
|
||||
def set_event_loop(self, loop):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue