File tree Expand file tree Collapse file tree 2 files changed +14
-15
lines changed
Expand file tree Collapse file tree 2 files changed +14
-15
lines changed Original file line number Diff line number Diff line change @@ -46,12 +46,10 @@ async def run_forever(
4646 while True :
4747 try :
4848 await async_callable ()
49- except RuntimeError as exc :
50- if "no running event loop" in str (exc ):
51- _logger .exception (
52- "Something went wrong, no running event loop, skipping execution of %s" ,
53- async_callable .__name__ ,
54- )
49+ except RuntimeError :
50+ try :
51+ asyncio .get_running_loop ()
52+ except RuntimeError :
5553 return
5654 except Exception : # pylint: disable=broad-except
5755 if not asyncio .get_event_loop ().is_running ():
Original file line number Diff line number Diff line change @@ -105,15 +105,16 @@ async def _run_loop(self) -> None:
105105 _logger .info ("Actor %s: Cancelled." , self )
106106 raise
107107 except Exception as exc : # pylint: disable=broad-except
108- if isinstance (exc , RuntimeError ) and "no running event loop" in str (
109- exc
110- ):
111- _logger .exception (
112- "Something went wrong, no running event loop,"
113- " not trying to restart %s again." ,
114- self ,
115- )
116- break
108+ if isinstance (exc , RuntimeError ):
109+ try :
110+ asyncio .get_running_loop ()
111+ except RuntimeError :
112+ _logger .exception (
113+ "Something went wrong, no running event loop,"
114+ " not trying to restart %s again." ,
115+ self ,
116+ )
117+ break
117118 if self ._is_cancelled :
118119 # If actor was cancelled, but any tasks have failed with an exception
119120 # other than asyncio.CancelledError, those exceptions are combined
You can’t perform that action at this time.
0 commit comments