question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Shift-Enter to run a cell is not cached

See original GitHub issue

Description

What steps will reproduce the problem?

If you have two consecutive code cells (starting with a #%%) and you try to run them both by pressing Shift-Enter twice, only the first cell will be run.

This happens when the first cell takes some time to run, and it’s still running when you press the second shift-enter. The second shift-enter is ignored.

In version 3.X it works fine, running the two cells one after the other.

Versions

  • Spyder version: 4.0.0b3
  • Python version: 3.7.3
  • Qt version: 5.12.3
  • PyQt5 version: 5.12.2
  • Operating System: Windows 10

Dependencies

pygments >=2.0    :  2.4.2 (OK)
qdarkstyle >=2.6.4:  2.7 (OK)
sphinx >=0.6.6    :  2.1.0 (OK)
pyls >=0.27.0     :  0.27.0 (OK)
nbconvert >=4.0   :  5.5.0 (OK)
pandas >=0.13.1   :  0.24.2 (OK)
numpy >=1.7       :  1.16.4 (OK)
sympy >=0.7.3     :  None (NOK)
cython >=0.21     :  0.29.10 (OK)
qtconsole >=4.5.0 :  4.5.1 (OK)
IPython >=4.0     :  7.5.0 (OK)
matplotlib >=2.0.0:  3.1.0 (OK)
pylint >=0.25     :  2.3.1 (OK)

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:10 (10 by maintainers)

github_iconTop GitHub Comments

2reactions
impact27commented, Aug 31, 2019

Yeah that’s great idea. Definitely the way to go. The queue would then be a simple list of command strings and the cache would be a dictionary of code and hashes. We can have Spyder do all the code caching separately when it adds to the queue.

We could add an optional parameter to the runcell and runfile like cache=None which would be a little cleaner than adding it to the cellname and then having to parse it. Then we would be be able to cache whole files for runcell as well(the imported modules could still change but we have to stop somewhere).

I think this is the correct way of doing this. I modified runfile in https://github.com/spyder-ide/spyder/pull/10115 to get the code from the editor, so we could even cache runfile. When this PR is merged, a cache parameter can be added to _handle_get_file_code and handle_run_cell.

0reactions
bcolsencommented, Aug 30, 2019

One way I can think of would be to add something to the cell name: if we want to run the cell “do stuff”, and the kernel is busy, we could cache the cell content and give it a name like “do Stuff @ cache:1234”. When the line is executed, the run_cell function will ask the frontend for the code for cell “do Stuff @ cache:1234”, and the frontend could pop the cache. This way we don’t need to modify the kernel.

Yeah that’s great idea. Definitely the way to go. The queue would then be a simple list of command strings and the cache would be a dictionary of code and hashes. We can have Spyder do all the code caching separately when it adds to the queue.

We could add an optional parameter to the runcell and runfile like cache=None which would be a little cleaner than adding it to the cellname and then having to parse it. Then we would be be able to cache whole files for runcell as well(the imported modules could still change but we have to stop somewhere).

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to cache in IPython Notebook? - Stack Overflow
When you execute this cell the first time, the code is executed, and the variables var1 and var2 are saved in mycache.pkl in...
Read more >
Executing and caching your content - MyST-NB
MyST-NB can automatically run and cache notebooks contained in your project using jupyter-cache. Notebooks can either be run each time the documentation is ......
Read more >
VS Code: Shift+Enter does not send code to Python Interactive
In my case, the Shift+Enter shortcut is "allocated" (for lack of a better word) to "Run Selection/Line in Python Terminal" AND also to...
Read more >
Unshare a data cache between PivotTable reports
Click any cell in the PivotTable report for which you want to unshare the data cache. On the Options tab, in the Data...
Read more >
Cache - Web APIs | MDN
Items in a Cache do not get updated unless explicitly requested; ... Make sure to version caches by name and use the caches...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found