-
Notifications
You must be signed in to change notification settings - Fork 5
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
Is there a way to have select do one and only one action ? #1
Comments
Hi, |
It's based on https://docs.python.org/3/library/asyncio-task.html#asyncio.wait and |
Nope, it's really needed and can contain values. So you have to process them (maybe forward/put back in your case?). |
Thank you very much for your answers :) Putting them back is a good idea, but I'm not familiar with asyncio enough to know whether this can be done with a guarantee that no other goroutine is putting something before the value we just read. Maybe putting the asyncio.wait and the putting back of extraneous values in a critical section ? I'll work on it. Would you consider a pull request in that sense, maybe with a keyword argument to select so that existing code gets the expected behavior, but go-style select is possible ? If so, I'll propose the matter to one of my interns. Cheers, |
This was just an educational project for me, I'm happy if it has a use and promotes async Python ;) and there is much room for improvements here, please provide PR's or maintain a fork of this project. The default event loop is slow and it would be interesting to run it on another one - but even then Python has its limits ;) |
For the reference: in my experience getting |
Thanks @navytux - I was looking for a working |
You are welcome, @dumblob; thanks for feedback. |
I've been banging my head on this problem for some time, and someone showed this library (which looks quite nice, congrats:) to me, but is is unclear to me if the semantics of select are the same as in Go:
Sometimes, in Go, my code relies on the fact that only one of the channel read or write passed to select actually happened.
If I send one value in channel c1 and another value in channel c2, and then select them both, and e.g. c1's read is chosen by the select and I discard its third return value, is there a guarantee that's c2's value is still available, or is there a possibility that it is lost ?
My problem here is that c2 may have been given to another goroutine, which does not have any access to the context where the third return value of the select call exists, and I may need this coroutine to have access to c2's value.
I hope my question is clear, if not, I'll try my best to clarify.
The text was updated successfully, but these errors were encountered: