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

Feature request - Queue.abort() #2016

Open
davidkhess opened this issue Jan 30, 2024 · 0 comments
Open

Feature request - Queue.abort() #2016

davidkhess opened this issue Jan 30, 2024 · 0 comments

Comments

@davidkhess
Copy link

davidkhess commented Jan 30, 2024

Would like to make a feature request for the Queue class: the ability to throw errors to all greenlets that may be waiting on a Queue.put() or Queue.get() on that queue and to any future calls to those two APIs on that particular Queue instance.

The use case is a Queue might be part of a more complicated structure of gevent resources stitched together to accomplish a task. If an error occurs (say a greenlet dies or a resource like a serial port closes), the simplest way to recover is to just tear it all down and rebuild it again. For that to happen cleanly without leaking resources, we need a way to cause all current greenlets waiting on get()s or put()s and any future calls to those methods to return an error.

The workaround I'm using at the moment is using getcurrent() to track every greenlet that is entering a potentially blocking Queue.get() or Queue.put() call and then iterating over that list and kill()ing them.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant