-
Notifications
You must be signed in to change notification settings - Fork 16
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
feat: add thread parameter to connection method, allowed "queued connections" #200
Conversation
CodSpeed Performance ReportMerging #200 Summary
|
Codecov ReportPatch coverage:
Additional details and impacted files@@ Coverage Diff @@
## main #200 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 18 21 +3
Lines 1571 1630 +59
=========================================
+ Hits 1571 1630 +59
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report in Codecov by Sentry. |
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.
I try to suggest an extension of this to provide a queue per thread. What did you think? Maybe weakkeydict should be used.
Thanks! Will look at this closer tomorrow. Do you generally like this pattern better on the whole? |
Yes. I prefer it as the user decides if use queued connections. |
Co-authored-by: Grzegorz Bokota <bokota+github@gmail.com>
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.
there was bug in my comments
Co-authored-by: Grzegorz Bokota <bokota+github@gmail.com>
Co-authored-by: Grzegorz Bokota <bokota+github@gmail.com>
Co-authored-by: Grzegorz Bokota <bokota+github@gmail.com>
question regarding API on the connect method @Czaki ... I find I don't love the name
where
we could also accept the special strings or do you prefer the words |
I like this suggestion to pass thread as primary type. |
so, no conveniences around string? user must import from threading in order to use it? |
Yes. Support for main and current is a good idea. As we do not have an idea for moving object semantics, then it is better than direct and queued. |
one more question. I'm inclined to default to the following behavior (most similar to "auto connection" on Qt):
This avoids the surprising behavior of using in code, the QueuedCallback object would then look like this: class QueuedCallback(WeakCallback):
def cb(self, args: tuple = ()) -> None:
if current_thread() is self._thread:
self._wrapped.cb(args)
else:
QueuedCallback._GLOBAL_QUEUE[self._thread].put((self._wrapped.cb, args)) do you agree? |
Hm. It looks like the best solution for now. |
maybe also https://github.com/pyapp-kit/psygnal/blob/main/docs/usage.md should be updated? |
i'll do that in a follow up. I think i will also deprecate the |
excited about this! thanks a lot for your input @Czaki |
alternative to #199 ... hat-tip to @Czaki for the inspiration.
somewhat closer to realizing #198
run this script as an example