-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
ZMQError when running code in the console #20381
Comments
Hi @raphaelquast thank you for the feedback! After Pyzmq released v25 we have had a related issue with Pyzmq (#20359) which was fixed over jupyter-client at PR jupyter/jupyter_client#914 What do you think @ccordoba12 ? This is something that should be fixed over jupyter-client too, right? |
@dalthviz thanks for the quick response! By the way... Now that I've been working a bit with the fresh spyder installation File "...\envs\rt1\lib\asyncio\events.py", line 80, in _run
self._context.run(self._callback, *self._args)
File "...\envs\rt1\lib\site-packages\tornado\platform\asyncio.py", line 647, in _handle_select
self._handle_event(r, self._readers)
File "...\envs\rt1\lib\site-packages\tornado\platform\asyncio.py", line 661, in _handle_event
callback()
File "...\envs\rt1\lib\site-packages\tornado\platform\asyncio.py", line 206, in _handle_events
handler_func(fileobj, events)
File "...\envs\rt1\lib\site-packages\zmq\eventloop\zmqstream.py", line 614, in _handle_events
zmq_events = self.socket.EVENTS
File "...\envs\rt1\lib\site-packages\zmq\sugar\attrsettr.py", line 56, in __getattr__
return self._get_attr_opt(upper_key, opt)
File "...\envs\rt1\lib\site-packages\zmq\sugar\attrsettr.py", line 68, in _get_attr_opt
return self.get(opt)
File "zmq/backend/cython/socket.pyx", line 512, in zmq.backend.cython.socket.Socket.get
File "zmq/backend/cython/socket.pyx", line 270, in zmq.backend.cython.socket._getsockopt
File "zmq/backend/cython/checkrc.pxd", line 28, in zmq.backend.cython.checkrc._check_rc
zmq.error.ZMQError: Unknown error
(... and just to take away the question... I'm already using |
Thanks for the extra info and new tracebacks! I think we should take care of those internal errors too for Spyder 4.5.2 (fixes that most probably need changes over jupyter-client). What do you think @ccordoba12 ? |
That's just a warning and I think it'll be fixed in Jupyter-client 8. So there's nothing we can do about it for now.
@raphaelquast, you have to give us a reproducible code example to test it in our side and see how we could fix it. So far, no one else has reported that kind of problems, so we can't be sure if they are related to PyZMQ 25. |
@ccordoba12 thanks for the response! I know that the initial message is a warning but the I'll do a completely fresh setup as soon as possible and report back if the issues persist! |
@ccordoba12 🐞 traceback
The commands I use to create the env is:
(first 2 lines only switch the conda-solver to libmamba as described here (I've used From my side there is absolutely no indication why this is happening... I'm happy to test suggestions! |
Ok, please downgrade to PyZMQ 24 and try again:
|
@ccordoba12 Yep, that did the trick just fine, all issues and warnings are now gone and spyder runs as nice and smooth it used to! |
Hey @ccordoba12 , sorry for having to revert my previous statement... While spyder is no longer showing any issues when using To be more precise: Somehow it is no longer possible to autocomplete beyond base-classes and functions... Do you know what's going on here or any temporary fix so that I can get autocompletion back? |
... just another update with my latest findings (since I really like to get my completions back somehow and at the moment I'm not sure how to even quick-fix this) It seems that auto completion works if I assign the objects to names, e.g.:
This procedure works at arbitrary levels (e.g. as long as I always assign a name to the object I want to autocomplete) Also... autocompletion in the editor-pane works (as long as it's not about attributes added at runtime)... so its really just the console that somehow stopped working |
Could it be that the constraint update done to support IPython 8.x is the one causing the console completion failures for you @raphaelquast ? What happens with the completion in |
Hey @dalthviz First, I tried completions in a Then I downgraded to Finally I re-installed To sumarize:
|
Note: probably we should create an issue for the completion not working properly on the console when using IPython 8.x |
Is there a separate issue already for "using IPython 8 causes auto-completion in the console to fail (beyond the first level of attributes)"? Is it still worth opening? |
Yes, there is: it's issue #20393. |
Never feel bad about pinging me on pyzmq issues! I'll look into it now. |
I believe I know the general idea of what's happening. Spyder's debug logs helped, because they show that it follows
pyzmq 25 is relevant because if ZMQStream is given an unsupported socket type (as jupyter-client 7 does, hence the warning at ZMQStream creation time), it uses a shadow socket to avoid making callbacks with the wrong types. The one downside of shadow sockets (a second Python object pointing to the same underlying zmq socket) is that one can be closed without the other noticing. When that happens, the next zmq API call on the socket may fail with a ZMQError. It should generally be ENOTSOCK (as above), though it's a bit worrying that there's one report of Ultimately, what's happening is that a libzmq socket is being closed while a ZMQStream is still using it. This may be due to a threading race condition in jupyter-client. I believe the right fix for this is in pyzmq to add a guard on |
Thanks for your help @minrk! How did you manage to generate the error (I've been unable to)? That way I can patch both PyZMQ and Jupyter-client with your changes and tell you if that fixes this problem on my side. |
I opened zeromq/pyzmq#1848 which should fix the issue in pyzmq (handling socket being closed somewhere else) and jupyter/jupyter_client#936 which should fix it in jupyter-client (explicitly close the stream before closing the socket). I don't really understand where problematic behavior would likely come from, though, because if I've understood the failure correctly, this should only be a log of unhandled error and moving on. It's possible there's a second, related bug I'm still missing. It also may be in the failure to close the stream, which leaves an event listener on the FD, which may be reclaimed by a future socket, but I really don't know about that.
I've actually struggled to reproduce the error. It's happened a couple of times, but I cannot provoke it reliably. Since it's a threadsafety issue, it's challenging. To provoke the issue above, I think you have to:
This may be more likely to occur on Windows, where select occurs in yet another thread, increasing the time between event registration and event handling, on account of proactor only being a partial asyncio event loop implementation. |
Left a tiny review for you there.
Unfortunately, I don't have a recent Windows VM to test this. Besides, it seems the test you added in your PyZMQ PR works pretty much in the same way as the steps you described above, right? So, that looks good to me. |
@ccordoba12 Not sure I can be much of help here on the programming side, but if you give some instructions on how to test the fixes, I'm happy to provide feedback if all works as expected on windows! |
@raphaelquast if you upgrade to jupyter-client 8.1.0 and/or pyzmq 25.0.2, that should test whether the fixes are working. |
Thanks @minrk I tried installing but [click to show] mamba downgrade summary
running
any idea why it searches for a unix version on windows? |
@raphaelquast, the problem is Spyder-kernels doesn't support Jupyter-client 8 yet. But we'll fix that in our next version (2.4.3) to be released alongside Spyder 5.4.3. |
@ccordoba12 OK, thanks for the clarification! Feel free to ping me if you want someone to check if this issue persists on windows once Spyder 5.4.3 is released! |
You should be able to test just pyzmq 25.0.2, which I think will be sufficient. |
I tried working a while with Thanks for taking care of this so quickly! However, in the process I also tested upgrading to IPython 8.11.0 in the hope that it fixes autocompletion as indicated by #20393 but unfortunately I have to report that on windows autocompletion still only works at the first level, e.g.:
Is there an issue addressing this behavior? (#20393 seems to be a different problem) |
Hey @minrk sorry to revert back on my previous comment... but unfortunately Now the following happens:
Exception in callback functools.partial(<bound method ThreadedZMQSocketChannel._flush of <qtconsole.client.QtZMQSocketChannel object at 0x0000020B619B4DC0>>)
Traceback (most recent call last):
File "D:\miniconda_NEW\envs\work\lib\site-packages\tornado\ioloop.py", line 740, in _run_callback
ret = callback()
File "D:\miniconda_NEW\envs\work\lib\site-packages\jupyter_client\threaded.py", line 183, in _flush
self.stream.flush()
File "D:\miniconda_NEW\envs\work\lib\site-packages\zmq\eventloop\zmqstream.py", line 483, in flush
self._check_closed()
File "D:\miniconda_NEW\envs\work\lib\site-packages\zmq\eventloop\zmqstream.py", line 685, in _check_closed
raise OSError("Stream is closed")
OSError: Stream is closed |
That shows that we also require the Jupyter-client fix @minrk did in its version 8.1.0 release to fully solve this problem. So, I added support for it to Spyder-kernels, which will be part of its 2.4.3 version.
That's not a bug in Spyder. It's actually a bug in IPython, so I'll report it there. A workaround for now is to go to
and enable the option called
However, you need to be aware that that could make the console slower when inspecting big dataframes or other large variables. That's why it's disabled by default. |
I think the Because of the async nature of how jupyter-client schedules this, there is a chance it's an issue in jupyter-client as well. The error doesn't propagate to the caller because of how it's scheduled on the IO Thread in jupyter-client, but I will fix that shortly. |
Thanks for your continued help @minrk! I must admit that I only skimmed the traceback above and since I saw it came from Jupyter-client, I assumed it was fixed by your jupyter/jupyter_client#936 PR.
Ok, thanks for pointing that out. I'll add a check before calling |
@raphaelquast, this should be fixed in IPython 8.13 thanks to the PR I opened for it: ipython/ipython#14029. |
Issue Report Checklist
conda update spyder
(orpip
, if not using Anaconda)jupyter qtconsole
(if console-related)spyder --reset
Problem Description
This is not really a problem so far since all is working as expected, but since this showed up on multiple
PCs where I did a fresh miniconda / spyder install, I thought I'll ask whats going on here...
What steps reproduce the problem?
conda install -c conda-forge spyder
What is the expected output? What do you see instead?
I'd expect spyder to start without any issues/warnings... however,
when I start spyder, the following shows up:
Versions
Dependencies
[click to show dependency list... ALL OK !]
The text was updated successfully, but these errors were encountered: