Spyder: Spyder freezes when typing in editor

Created on 15 Aug 2019  路  13Comments  路  Source: spyder-ide/spyder

Description

After using Spyder for some period of time, while typing in the editor Spyder suddenly becomes unresponsive and the cursor becomes the spinning beachball of death. The only way to proceed is to force quit Spyder (Activity Monitor confirms that the Python process is unresponsive).

FYI: I run Spyder from a dedicated Anaconda environment created by
>> conda create -n spyder-beta -c spyder-ide spyder

What steps will reproduce the problem?

I am uncertain what actions will reproduce the problem, other than to use Spyder for some period of time.

Versions

  • Spyder version: 4.0.0b4
  • Python version: 3.7.0
  • Qt version: 5.9.6
  • PyQt5 version: 5.9.2
  • Operating System: Darwin 18.7.0

Dependencies

pygments >=2.0    :  2.4.2 (OK)
qdarkstyle >=2.6.4:  2.7 (OK)
sphinx >=0.6.6    :  2.1.2 (OK)
psutil >=0.3      :  5.6.3 (OK)
pyls >=0.27.0     :  0.28.0 (OK)
nbconvert >=4.0   :  5.5.0 (OK)
pandas >=0.13.1   :  None (NOK)
numpy >=1.7       :  None (NOK)
sympy >=0.7.3     :  None (NOK)
cython >=0.21     :  None (NOK)
qtconsole >=4.5.2 :  4.5.2 (OK)
IPython >=4.0     :  7.7.0 (OK)
matplotlib >=2.0.0:  None (NOK)
pylint >=0.25     :  2.3.1 (OK)
Awaiting Followup Bug

Most helpful comment

I've had multiple freezes during past four weeks when typing in the Spyder editor . If I am working in Spyder longer than 1 hour it is almost guaranteed that I get a freeze. When I work in Spyder for multiple hours I usually have at least one freeze every 1-2 hours (I restart Spyder). My hunch is that it is related to code completions running in Spyder - I often got the freezes when a completion box was open/opening. Unfortunatelly it is hard to narrow this down as it happens approximately once an hour without very clear pattern.

All 13 comments

This is very vague, so I'm afraid we can't do anything about it unless you narrow down the circumstances a bit more.

You can also start Spyder in debug mode with:

spyder --debug-info verbose --debug-output file

then upload here the file called spyder-debug.log, present in the directory where you started Spyder.

@ccordoba12, thanks for responding. Yes, it is vague, unfortunately. My plan was to do just as you suggested and create a debug log file. I found another post mentioning "SPYDER_DEBUG=3", so I set that environment variable and redirected output to a log file.

>> export SPYDER_DEBUG=3
>> spyder >& file

Is there a difference between this and --debug-info verbose?

Is there a difference between this and --debug-info verbose?

Nop, it's just more user friendly.

Excellent. I'll post here as soon as I have something more substantive.

I seem to be having the same issue, and suspect that it may be related to the autocompletion functions. On several occasions Spyder froze when pressing tab to complete a function or variable name.

Okay, I can't say exactly how I froze spyder before other than it occurred while I was typing in the editor. However, I have been able to freeze spyder reproducibly by using the keyboard shortcut opt-shift-cmd-. (editor: next warning) in a file that does not have any warnings. Attached is the debug log file. Following are the steps to reproduce the issue with the log file line numbers generated during the process.

  1. Start Spyder (lines 1-527).
  2. Open a python file that doesn't have any codestyle warnings (I just used Spyder's default new file, but this file was already open from a previous Spyder start, so no entries were made in the debug log).
  3. Use the keyboard shortcut opt-shift-cmd-. (No log entries created).
  4. Observe spinning beachball of death (No log entries created).
  5. Force quit Python (lines 528-529)

spyder-2019-08-28-19-17-34.log

@mrclary I can confirm this. Will issue a fix (at least for that!)

@goanpeca , thanks. Any idea what this is related to? I imagine that the keyboard shortcut is related to the original reason I filed this issue. I believe that I was just lucky to stumble across it as this keyboard shortcut is not one that have used in the past.

The code is going into a while loop with no breaking condition under these circumstances.

        while True:
            if block.blockNumber()+1 < line_count:
                block = block.next()
            else:
                block = self.document().firstBlock()
            data = block.userData()
            if data and data.code_analysis:
                break

@mrclary I think this bug is similar but may not be exactly what you found. Now since the symptoms are similar, @ccordoba12 I think we need to audit all the code inside codeeditor.py where we are using a while loop. We are most likely missing breaking conditions.

I think we need to audit all the code inside codeeditor.py where we are using a while loop

I agree. That's the danger of using a while to do iterations.

@mrclary, we discovered why this is happening. We're tracing the problem on issue #10209.

I have the same problem. Spyder is often hanging when I am writing code, - I suspect it happens if I am typing too quickly. Maybe because the automatic syntax checking is not hanging on fast enough.

I've had multiple freezes during past four weeks when typing in the Spyder editor . If I am working in Spyder longer than 1 hour it is almost guaranteed that I get a freeze. When I work in Spyder for multiple hours I usually have at least one freeze every 1-2 hours (I restart Spyder). My hunch is that it is related to code completions running in Spyder - I often got the freezes when a completion box was open/opening. Unfortunatelly it is hard to narrow this down as it happens approximately once an hour without very clear pattern.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

hedeqing picture hedeqing  路  3Comments

ok97465 picture ok97465  路  3Comments

spyder-bot picture spyder-bot  路  3Comments

gabrielclow picture gabrielclow  路  3Comments

impact27 picture impact27  路  3Comments