Add loop
argument to signal router finalize
method to finalize without having a running loop
Closes #2829
This commit is contained in:
parent
a5a9658896
commit
45b6e6d8c4
|
@ -277,7 +277,7 @@ class SignalRouter(BaseRouter):
|
||||||
|
|
||||||
return cast(Signal, signal)
|
return cast(Signal, signal)
|
||||||
|
|
||||||
def finalize(self, do_compile: bool = True, do_optimize: bool = False):
|
def finalize(self, do_compile: bool = True, do_optimize: bool = False, loop: asyncio.AbstractEventLoop = None):
|
||||||
"""Finalize the router and compile the routes
|
"""Finalize the router and compile the routes
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
|
@ -293,7 +293,7 @@ class SignalRouter(BaseRouter):
|
||||||
self.add(_blank, "sanic.__signal__.__init__")
|
self.add(_blank, "sanic.__signal__.__init__")
|
||||||
|
|
||||||
try:
|
try:
|
||||||
self.ctx.loop = asyncio.get_running_loop()
|
self.ctx.loop = loop or asyncio.get_running_loop()
|
||||||
except RuntimeError:
|
except RuntimeError:
|
||||||
raise RuntimeError("Cannot finalize signals outside of event loop")
|
raise RuntimeError("Cannot finalize signals outside of event loop")
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user