Open dragos-vlad opened 6 years ago
I'm also getting this exception when the application closes.
Exception ignored in: <bound method Socket.__del__ of <zmq.asyncio.Socket object at 0x7f3901bb4e18>>
Traceback (most recent call last):
File "/usr/local/lib/python3.6/site-packages/zmq/sugar/socket.py", line 66, in __del__
self.close()
File "/usr/local/lib/python3.6/site-packages/zmq/_future.py", line 157, in close
self._clear_io_state()
File "/usr/local/lib/python3.6/site-packages/zmq/asyncio/__init__.py", line 60, in _clear_io_state
self.io_loop.remove_reader(self._fd)
File "/usr/local/lib/python3.6/asyncio/selector_events.py", line 342, in remove_reader
return self._remove_reader(fd)
File "/usr/local/lib/python3.6/asyncio/selector_events.py", line 279, in _remove_reader
key = self._selector.get_key(fd)
File "/usr/local/lib/python3.6/selectors.py", line 189, in get_key
return mapping[fileobj]
File "/usr/local/lib/python3.6/selectors.py", line 70, in __getitem__
fd = self._selector._fileobj_lookup(fileobj)
File "/usr/local/lib/python3.6/selectors.py", line 224, in _fileobj_lookup
return _fileobj_to_fd(fileobj)
File "/usr/local/lib/python3.6/selectors.py", line 39, in _fileobj_to_fd
"{!r}".format(fileobj)) from None
ValueError: Invalid file object: None
do DISH sockets not have zmq.FD? If so, then they cannot be used with asyncio.
@minrk How do I find out?
Looks like it was an explicit design choice in libzmq to not support ZMQ_FD (https://github.com/zeromq/libzmq/issues/2941) in new threadsafe sockets (server/client, radio/dish, scatter/gather). Until that's fixed, you won't be able to use these sockets with asyncio or tornado. I wouldn't recommend using any of the draft-api sockets in production.
Like you mentioned in the libzmq issue it's pretty important for the final version of the sockets to expose a way for event loops to work with them. Until then I recommend we keep this issue open.
Thanks for your help.
EDIT: The docs should be updated in order to reflect the current status. If you like I could update them and make a pull request.
Adding a note to draft support that libzmq draft sockets cannot be used with eventloops would be worthwhile. Thanks!
Was poking around with RADIO/DISH and asyncio, stumbled onto this issue. I've gone through some of the genesis of the problem. Do we know if this is still an issue in libzmq?
Yes, still an issue and no indication of progress. It's a tricky problem and someone needs to implement it in libzmq.
Hi, It would be very nice if this can be implemented or even some hints of how to implement/what to look into. Thanks,
This is a feature request for libzmq to implement event-loop-supporting handles for sockets. Until they address that, there isn't really anything pyzmq or users can do, other than do blocking calls in background threads. If DISH sockets get ZMQ_FD support, it should work with asyncio without any changes to pyzmq. If they choose to go another way, it might require some code in pyzmq to deal with it. There is a proposal that sounds like it would work, to me, but someone has to implement it in libzmq.
Thanks for explaining that @minrk, I will try to see if there is an open issue at libzmq side and create relationship.
Hi,
I'm trying to initialise a DISH socket using
zmq.asyncio.Context
fails with:The code i'm using is:
Initialising the socket with
zmq.Context
works as intended.System Info: