Spyder: TimeoutError when running cells after a kernel restart

Created on 19 Dec 2019  路  18Comments  路  Source: spyder-ide/spyder

Full traceback below; cell runs fine via highlight + "Run selection or current line"; behavior's fixed upon restarting kernel, but returns randomly after finishing a TensorFlow training session (didn't test in other settings).

Traceback (most recent call last):

  File "D:\Anaconda\envs\s4_env\lib\site-packages\spyder_kernels\comms\commbase.py", line 542, in __call__
    call_dict, call_data, self._comm_id)
  File "D:\Anaconda\envs\s4_env\lib\site-packages\spyder_kernels\comms\commbase.py", line 415, in _get_call_return_value
    self._wait_reply(call_id, call_name, timeout)
  File "D:\Anaconda\envs\s4_env\lib\site-packages\spyder_kernels\comms\frontendcomm.py", line 161, in _wait_reply
    call_name))

TimeoutError: Timeout while waiting for 'run_cell' reply

Update: reproduced immediately after restarting kernel and working with basic numpy operations


Update 2: interrupting frozen run-cell command yields below:

Traceback (most recent call last):

  File "<ipython-input-4-633e420a5051>", line 1, in <module>
    runcell('[], #5', 'C:/DL_code/dev_ensemble_subset.py')
  File "D:\Anaconda\envs\s4_env\lib\site-packages\spyder_kernels\customize\spydercustomize.py", line 539, in runcell
    cell_code = frontend_request().run_cell(cellname, filename)
  File "D:\Anaconda\envs\s4_env\lib\site-packages\spyder_kernels\comms\commbase.py", line 542, in __call__
    call_dict, call_data, self._comm_id)
  File "D:\Anaconda\envs\s4_env\lib\site-packages\spyder_kernels\comms\commbase.py", line 415, in _get_call_return_value
    self._wait_reply(call_id, call_name, timeout)
  File "D:\Anaconda\envs\s4_env\lib\site-packages\spyder_kernels\comms\frontendcomm.py", line 167, in _wait_reply
    time.sleep(0.01)

KeyboardInterrupt
IPython Console Bug v4.1.0

Most helpful comment

I can't reproduce on mac. A workaroud could be to select this in the settings:
Screenshot 2019-12-28 at 17 21 12

All 18 comments

@impact27, what do you think we should do about this?

Is the frontend frozen when you see that? I ask because this function is here for the kernel to ask the frontend for the cell code. Are you using a remote kernel? Is there any text in the front end internal console? (View > Panes > internalconsole)

@impact27 If by "frontend" you mean the usual / default Spyder interface, then yes; I've never used any consoles besides the IPython kernel, including internal console. I haven't reproduced this issue since, so unsure what the internal console outputs when it occurs - but will look out for next occurrence.

@impact27 Happened again now, I checked the internal console - it logged something:

image

However, unsure whether it emerged out of the timeout error, as it failed to log again when I repeated the error.

@impact27 @ccordoba12 Finally found a reproducible instance:

demo1.mp4
demo2.mp4

Edit: nevermind, not so "reproducible" for you - just found a much better one, will edit

It seems that that's related to the code you're programming in Spyder. Could you share it with us?

@ccordoba12 Finally an actually reproducible snippet: s4_demo3.mp4. Note that it doesn't _always_ occur - for me it happens every other attempt or so.

same issue with me ... i wish i wanna fix it but, there are no any advices apart from only this .. please help !!

@doggyulee For an alternative, you can highlight the code in the cell and "Run selection":

image

I can't reproduce on mac. A workaroud could be to select this in the settings:
Screenshot 2019-12-28 at 17 21 12

I can reproduce with windows. This is caused by the comm port not being set.

  • We should not try to send a reply from the frontend without this port being open. this should be an error.
  • I don't know why the port is not set on restart sometimes, this looks like a race condition.

More specifically, it looks like spyder_kernels/comms/frontendcomm.py::_comm_open is not called??

The real workaround is to simply close the tab and don't restart the kernel.

@impact27 Great, will mark this solved and reopen if it recurs in the next release - thanks

will mark this solved and reopen if it recurs in the next release - thanks

Please don't do that for next time. Issues are marked as solved once their associated pull requests are merged.

@ccordoba12 Indeed, I celebrated too early; recurred in Spyder 4.0.1, installed via conda. Identical error trace.

This will be fixed in Spyder 4.1, to be released in a couple of months. In the meantime, please switch to the old way of evaluating cells, as described here:

https://stackoverflow.com/a/59494870/438386

I had the same error, and I fixed it easily. In my case, the reason was that I had two different versions of spyder on my "base environment v4.1.4" and "virtual environment" that I installed through anaconda-navigator manually.

Was this page helpful?
0 / 5 - 0 ratings