Skip to content

Commit 45b6e6d

Browse files
authored
Add loop argument to signal router finalize method to finalize without having a running loop
Closes sanic-org#2829
1 parent a5a9658 commit 45b6e6d

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

sanic/signals.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ def add( # type: ignore
277277

278278
return cast(Signal, signal)
279279

280-
def finalize(self, do_compile: bool = True, do_optimize: bool = False):
280+
def finalize(self, do_compile: bool = True, do_optimize: bool = False, loop: asyncio.AbstractEventLoop = None):
281281
"""Finalize the router and compile the routes
282282
283283
Args:
@@ -293,7 +293,7 @@ def finalize(self, do_compile: bool = True, do_optimize: bool = False):
293293
self.add(_blank, "sanic.__signal__.__init__")
294294

295295
try:
296-
self.ctx.loop = asyncio.get_running_loop()
296+
self.ctx.loop = loop or asyncio.get_running_loop()
297297
except RuntimeError:
298298
raise RuntimeError("Cannot finalize signals outside of event loop")
299299

0 commit comments

Comments
 (0)