-
Notifications
You must be signed in to change notification settings - Fork 66
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
Easy API for having context span threads #247
Conversation
""" | ||
with startAction(action_type="parent"): | ||
wrapped = preserve_context(self.add) | ||
self.assertEqual(wrapped(3, y=4), 7) |
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.
Lines 1424 and 1425 in a helper function that this test method and test_no_context
can both call?
❓
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 think with only two callers and two lines it doesn't end up being shorter. But yeah, if there were more of them.
Thanks. This is a nice addition. Relatedly, this past week I've been noticing that even some single-threaded code manages to lose the parent/child association - if it's asynchronous. Lots of code uses Deferred without being Eliot-aware at all. Any time execution has to jump to a callback on a Deferred, the Eliot context gets lost. That's a bit sad. It seems like this I guess thread-using code may possibly suffer an equivalent problem. This helper doesn't help if you don't use it and you may want to call existing code that doesn't know about Eliot. Not sure what to do about that, though. Anyhow, this looks like a useful helper for the case where Eliot-aware code does control the dispatch-to-thread piece, so, great. Just a few minor points inline. Address to your satisfaction and then merge. |
Yeah, making stuff Just Work is hard with async and threaded code. A sub-class of |
Easy API for having context span threads. Fixes #225.
Fixes #225.