-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Signals refacoting #2480
Signals refacoting #2480
Conversation
@pfreixes the RP breaks your work on client tracing but I pretty sure the change is not big and is done for good. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should changes mention drop on_pre_signal
and on_post_signal
?
Sure. |
Codecov Report
@@ Coverage Diff @@
## master #2480 +/- ##
==========================================
+ Coverage 97.14% 97.15% +0.01%
==========================================
Files 39 39
Lines 8136 8097 -39
Branches 1420 1416 -4
==========================================
- Hits 7904 7867 -37
+ Misses 101 99 -2
Partials 131 131
Continue to review full report at Codecov.
|
class PostSignal(DebugSignal): | ||
|
||
__slots__ = () | ||
await receiver(*args, **kwargs) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about to add more friendly exception if plain func is going to be registered as handler? I guess now such code will fail with cryptic TypeError: object NoneType can't be used in 'await' expression
or similar.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you suggest catching TypeError
and raise a new TypeError
with more informative exception message?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As an option we could check ll callbacks on freezing stage.
It prevents registering a regular function which returns a future but it's fine I guess.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes for TypeError and yes, better check this early. On append call if possible. The stacktrace will help to find that bad signal usage with easy.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FrozenList can be modified by too many ways, .append
is not the only one.
I think .freeze()
is a good compromise.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's a pity. Ok then if error message would contains function name which is not async.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, but I see you point.
Maybe we need specialized CheckedFrozenList
class with registered callback? It could improve UX slightly.
Please let me merge the PR as is and make a new issue.
I don't want to block @pfreixes with his client tracing PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok. Let's do that.
LGTM. Just take into account that Func signals might be needed later, but let's implement it once we know for sure that are gonna needed. |
@asvetlov what was intention to remove support of synchronous functions? We had to refactor all our backends due to this decision. Why not to write Also, about automatic detection: |
|
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a [new issue] for related bugs. |
Fix for #2419