Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Question: Channels will never support queue-like polling interface? #51

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

Open
dumblob opened this issue Sep 2, 2019 · 1 comment
Open

Comments

@dumblob
Copy link

dumblob commented Sep 2, 2019

Currently PEP 554 states, that the idea of channels acting like queues was rejected.

I'm a bit surprised about that as single-producer-single-consumer queues (e.g. a ring buffer) are basically the most efficient known structures to share data in small batches (potentially of varying sizes in runtime) between operating system threads running on different physical CPU cores.

My question has thus 2 parts:

a) Is it expected, that Python at some point in the future will "promote" the currently single-item send() and recv() to batch variants supporting buffering? Or will this be rejected as well in the future and not implemented thus leaving Python with the same issue as in Go (see some details):

"it turns out that nearly every single team that has tried to scale golang servers has come to the same position. Give up channels as your concurrency primitives and revert to the sync package if you need to really scale golang programs"

b) Will Python add support for polling interface (poll_send(), poll_recv()) on the channels additionally to the current send() and recv() interface? Note, this does not imply support for timeouts though admittedly it could be achieved also with them.

@ericsnowcurrently
Copy link
Owner

The main goal of the PEP is to get to a minimum level of functionality. We can build from there. So I guess the answer to all your questions is "we can work that out later". :) That said, I don't see a problem with expanding the capability of channels in the ways that you've described (though you'd need to do the work or find someone to do it). It's too early to promise anything, so let's revisit this after PEP 554 is accepted and the implementation merged.

Also, keep in mind that the PEP 554 implementation is effectively just an extension module. Alternate sharing mechanisms, e.g. something more similar to queue.Queue, shouldn't be that hard to implement and publish to PyPI.

I'll keep this issue open for later discussion.

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

2 participants