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

Rfc/git 1630 signals #1902

Closed
wants to merge 6 commits into from
Closed

Rfc/git 1630 signals #1902

wants to merge 6 commits into from

Conversation

ahopkins
Copy link
Member

@ahopkins ahopkins commented Aug 2, 2020

Take over from #1770 re: #1630

@ashleysommer
Copy link
Member

@ahopkins
Thanks for taking this over. I'm very interested in this Signals work, because it is integral for the future of Sanic-Plugins-Framework.
I'll read over the proposed implementation and see if I can offer feedback.

@@ -146,7 +152,7 @@ def register_listener(self, listener, event):
:param event: when to register listener i.e. 'before_server_start'
:return: listener
"""

subscribe(event_name=event, callback=listener, signals=self.signals)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If self.listener() decorator calls subscribe() (on line 141 above) then why does this helper function also need to call subscribe()? Wouldn't this result in two subscribes with the same listener and signals?

def get(
self, uri, host=None, strict_slashes=None, version=None, name=None
):
def get(self, uri, host=None, strict_slashes=None, version=None, name=None):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like quite a lot of the changes in this file are formatting changes, was that just a result of merging in latest master? Or should these formatting changes be filtered out?



def _extract_signal_namespace(event_name, signals):
global _CLASSIC_EVENT_ALIAS
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can this be done without using a global variable?

@@ -3,6 +3,9 @@
from importlib import import_module
from inspect import ismodule

from sanic.signals import Namespace
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like Namespace is only imported for Type checking, so has no purpose at runtime.

This import can changed to:

if typing.TYPE_CHECKING:
    from sanic.signals import Namespace

Then in type declarations, change Namespace to 'Namespace' (string form)

"request": Namespace(namespace="request", owner=self),
"response": Namespace(namespace="response", owner=self),
"middleware": Namespace(namespace="middleware", owner=self),
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like 4 Namespaces of signals are defined, but signal emitters are only implemented for server signals. Are the others planned to be implemented?

@ahopkins
Copy link
Member Author

ahopkins commented Aug 3, 2020

I think this is a really great potential win. I've been playing with the branch, and have some ideas on how to refine the implementation. I'll post on the RFC thread some changes I'm thinking about. One is to scrap the additional dependency and just roll our own signaling solution.

@ahopkins ahopkins marked this pull request as draft September 27, 2020 08:26
@stale
Copy link

stale bot commented Dec 31, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If this is incorrect, please respond with an update. Thank you for your contributions.

@stale stale bot added the stale label Dec 31, 2020
@ahopkins ahopkins added necessary and removed stale labels Dec 31, 2020
@ahopkins
Copy link
Member Author

Coming 2021

@ahopkins ahopkins mentioned this pull request Feb 28, 2021
@ahopkins ahopkins closed this Feb 28, 2021
@ahopkins ahopkins deleted the rfc/GIT-1630-signals branch February 28, 2021 13:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants