Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add loop argument to signal router finalize method to finalize without having a running loop #2830

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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