-
-
Notifications
You must be signed in to change notification settings - Fork 343
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
Implement select()/merge() on ReceiveChannels #1411
Comments
The main issue for discussing The tl;dr is that If we want to support this directly in the Trio core, then we should probably do it by providing a generic framework that lets arbitrary objects support Let's close this issue and continue the discussion in #242, to keep everything in the same place. I think the main two things that would help move this forward would be:
|
Oh, how could I not have found that thread? Thanks, I'll head over there. |
I want to receive values from multiple channels at once, and more importantly, receive only the first value from either of them. I have not found a good way to do that, at least with the libraries exported methods.
There's that
race
function example in the docs, and I can use something similar but it appears to have multiple problems:This looks like a large hole in the API surface of
trio
to me.There was some Gitter discussion about this in August 2019, but it seems nothing came out of it.
I think the first problem (multiple receives) can be fixed if I call
cancel
earlier, likewait_any
fromtrio-util
does it:However, I would prefer if there was a native way to do that without repeating this helper function in every project. I think it would rather easy to have a
MemoryReceiveChannel
that can receive from multiple producers, by just replacingthis._state
with an array of states and looping over them everywhere the state was used:The text was updated successfully, but these errors were encountered: