-
Notifications
You must be signed in to change notification settings - Fork 648
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
WIP: Enable Thread-Safe sockets with Asyncio using zmq_poller_fd #2065
base: main
Are you sure you want to change the base?
Conversation
for more information, see https://pre-commit.ci
for more information, see https://pre-commit.ci
for more information, see https://pre-commit.ci
Related issue: #1139 |
Awesome, thanks for working on this! I'll try to review when I have a chance. But in the meantime, one design goal I'd probably go with is not exposing the Poller object or class publicly, and instead implementing it entirely privately within |
I have moved the ZMQPoller object to private backend So, TLDR: I have removed it from the __all__ api, so has to be explicitly imported. On a side note, the ZMQ Poller is a first class object in the Draft api and it would be nice to expose it. I wonder what the performance would be if the pyzmq poller can be rewritten to use it, but that is an entirely separate topic.
I respectfully disagree on philosophical grounds, but I have updated the __del__ to a close() to get this pushed through |
Thanks!
Is the poller FD still POLLIN-only edge-triggered FD for 'events'? If so, it may behave the same, as long as we register it with POLLIN | POLLOUT in this case. I'm really not sure, I have no experience with these poller FDs. It is going to require quite a bit of testing. This is very new territory, thanks for exploring it.
Thanks for changing it! It's not really a philosophical point, though. An important fact that's not philosophical is that when you |
As far as I can tell, the poller fd is a read-only fd that edge triggers making the fd ready to read, like the normal socked fd. it triggers when the monitored sockets have events matching their mask. You definitely could just tell poller to trigger on both POLLIN and POLLOUT. You can definitely use this to shoe-horn in a low level so that it is all but invisible, but that doesn't make sense to me. I will try to work on some test cases and look into cffi. Also, please let me know when I need to rebase |
Part of the reason I was thinking of the FD behavior is that I think this is what libzmq should do itself (and hopefully will when someone has the time and inclination), so making pyzmq look as much as I think libzmq will/should ought to make the changes to pyzmq simplest, and (hopefully) can be removed when upstream someday fixes the bug. But if you think it's easier/simpler to do it at the
Thanks for asking. Don't worry about rebasing, it's easier to review if you don't. If the PR history gets messy, I can squash at merge time, but no reason to before then. |
Request for comments:
NOTE: This REQUIRES the Draft API
This enables Thread-safe sockets (Like RADIO/DISH and SERVER/CLIENT) to be used with asyncio.
Thread-safe sockets do not have a file-descriptor to use to detect events with asyncio. Instead, for each threadsafe socket, a 0MQ poller object is created, associating the socket, and asking for a file-descriptor for the 0MQ poller.
The zmq_poller_fd was added in ZMQ 4.3.2
Outstanding items:
Please note I am new to this project, so I do not know the conventions for pulls. Please correct me.