Skip to content

Commit

Permalink
Add loop argument to signal router finalize method to finalize wi…
Browse files Browse the repository at this point in the history
…thout having a running loop

Closes sanic-org#2829
  • Loading branch information
eelkevdbos committed Sep 27, 2023
1 parent a5a9658 commit 45b6e6d
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions sanic/signals.py
Expand Up @@ -277,7 +277,7 @@ def add( # type: ignore

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
Args:
Expand All @@ -293,7 +293,7 @@ def finalize(self, do_compile: bool = True, do_optimize: bool = False):
self.add(_blank, "sanic.__signal__.__init__")

try:
self.ctx.loop = asyncio.get_running_loop()
self.ctx.loop = loop or asyncio.get_running_loop()
except RuntimeError:
raise RuntimeError("Cannot finalize signals outside of event loop")

Expand Down

0 comments on commit 45b6e6d

Please sign in to comment.