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
Context manager for spawn #1324
Comments
Thanks for the suggestion! It's not clear to me that this is a widely used pattern, or one that's complex enough to get right that it needs to be in the gevent distribution, rather than a personal utility function. Especially since there are multiple ways to implement it (e.g., subclassing |
There is no good answer to this :-) All "proof" I can offer is that I've copied this recipe across multiple projects now and that I'd prefer having it in a single place rather than copy-pasting it in each new project.
I think that's a question of style preference and I don't really care much which style is used. I just want an idiomatic way to do it.
I like your suggesting of making |
It's still not clear to me that it's enough of a win over the current solution of |
I agree that this is not the most common idiom, hence my mention of this being mainly useful in test suites (your "toy examples"). If that's not enough of a convincing use case, here's another. I write a lot of code where I have a local proxy representation of some remote state. I launch background task that subscribes to change notifications for this remote state. As change notifications come in, the background task updates the local representation and then notifies that changes have occurred using a condition variable (which is why I also submitted issue #1326). I've written these programs successfully using standard threading and with |
OMG thanks for fixing this! I'm really looking forward to replacing my custom context manager with the standard one :-) |
Hi there!
Thanks for this awesome library, I really boosts my productivity :-)
I've found myself repeating this small context manager in multiple projects, mainly in test suites, to help ensure cleanup is performed properly. I think it might be useful for others as well and I'm wondering if it could be useful to include it in
gevent
itself as a standard idiom.Do you think it could be useful? If so, I could work on a PR :-)
Thanks!
André
The text was updated successfully, but these errors were encountered: