Is it possible to resume operation after pausing in jupyter - jupyter

Is it possible to pause the operation of jupyter while performing a computational intense task freeing the cpu and resume it later.

I realize this is very outdated, but I found a solution to this problem after searching for quite a while! I actually ended up trying a bunch of random combinations.
CTRL+S worked for me when using jupyter notebook with Anaconda.
You must be in the shell for this to work.
Also, other key combinations that didn't work for me but were suggested elsewhere include:
CTRL+Z
and
CTRL+I
Hopefully this can at least help out someone down the line...

In current Jupyter no such option. But you can try system tools
In case of Task manager in Windows:
Identify running process with name python.exe
Set low priority of the process with a click in popup menu
For more control try "Process Explorer".
It can Suspend command for the tree of processes.
Also see https://www.reddit.com/r/Python/comments/1spmpt/pause_a_running_python_script_and_resume_when/ for further tricks On Linux or Mac.

A solution that should work on a Mac or Linux (perhaps Winders too, but your mileage may vary). There should be a terminal window running Jupyter. Navigate to that terminal window and press Control-Z. It will suspend the job and put it in the background.
:
:
[I 13:24:05.147 NotebookApp] Saving file at /seisbench/examples/createGEOFON.ipynb
[I 13:25:04.858 NotebookApp] Saving file at /seisbench/examples/createGEOFON.ipynb
^Z
[1]+ Stopped jupyter notebook
To restart, type 'fg' in the terminal window to bring the job to the foreground. You could probably do a 'bg' to put it in the background too, but I did not test this.
(bds) LC02WR133HV2R:notebooks a0194920$ fg
jupyter notebook
[I 13:27:05.231 NotebookApp] Saving file at /seisbench/examples/createGEOFON.ipynb
:
During the time the application was stopped, all the Jupyter notebooks stopped updating. Once the application was placed back in the foreground, all the Jupyter windows continued where they left off. Good luck.

Related

Why terminal becomes unresponsive after Parcel build?

I am following Parcel's "Building a web app with Parcel" to learn how to use it. The problem arises after I type in npx parcel src/index.html. The build runs fine and I can see the development server results just fine. The terminal becomes unresponsive afterwards. I can't type, quit, or anything. The only workaround is killing the terminal and restarting...which is very annoying. I've looked for answers, I've updated Node to the latest version, but to no avail. This doesn't happen when I use Webpack or any other time. Here is a screen shot just in case that helps. Could someone please help this unworthy noob out? Screen shot of terminal and VSCode
When you just run npx parcel, it starts a development server that will continue to run until you exit. This development server will watch for changes that you make as you develop and will reload your project, so you don't need to restart/rebuild every time you make changes.
The reason you can't type anything into the terminal (or, at least, that the terminal doesn't respond when you do) is that the development server is still running in that terminal. You have to exit the development server before the terminal prompt will re-appear and you can use it as normal.
To exit any program running in a terminal, you can type Control+C (hold down the Control key and hit the "c" key). This works for any terminal program, not just parcel. This will exit the development server program and you'll get your terminal prompt back.
There are other things you can do with programs (or "jobs") in the terminal window. You can read more about them here and here.
But you should use the development server to your advantage. Keep it running while you work. If you need to use the terminal while it's running, just open up another terminal window.
When you finally want to build your app/site, run parcel build instead.
You can read more about all of this here: https://parceljs.org/getting-started/webapp/

VS Code Integrated terminal does not execute commands from extensions

Ideally, the integrated VS Code terminal, depending on the context, the type of the folder and the extension, executes some commands. For example, when opening a folder containing a Python virtual environment in VS code, the environment is recognized and activated (by the python extension) by default when opening a new integrated terminal instance (situation 1). This is done by running some command similar to source /path/to/venv/bin/activate.
Or, when using the ROS extension to debug nodes, selecting "Start Debugging (F5)" uses the launch.json file to start some nodes and finally starts debugging the desired code. To do so also, there is some command that is executed (also by he ROS extension, I assume) in the integrated terminal (situation 2) to start the debugging process. In case of debugging ROS nodes, the command usually looks something like /usr/bin/env /bin/sh /tmp/someFileName.
But, unfortunately, both of the above mentioned situations fail. I believe this happens because while the extension tries to run these two commands within their respective integrated terminals, the commands do not actually get executed in either situation. Instead, these commands are printed on the top of the terminal, but the state of the terminal is unchanged (as opposed to when the commands would have been executed, in which case depending on the commands some actions are performed). Here are two images to show what I mean. Top, situation 1 and bottom, situation 2.
The fact that these two commands are printed on top of the terminal as soon as the a new terminal instance is opened tells me that the extension tries to execute them, but they do not work for some unknown reasons.
Just to be clear, both of them are run in a seperate VC Code window, they have nothing to do with each other. When I manually run both the commands in their respective terminals I do get the desired results.
Now, I am unsure exactly how to name this issue. But I think this is surely an issue with the integrated terminal, and not a problem of the extensions. I am not sure how one could reproduce this problem.
I did a clean reinstall of VS code by deleting %APPDATA%\Code and %USERPROFILE%\.vscode. Because I am using this on WSL, there is only ~/.vscode-server on the ubuntu side. I manually uninstalled all extensions on WSL but did not delete this folder, in fear of breaking something. The problem still persisted. I have also created an issue on the VS Code GitHub page with nearly the same information.
I am unsure if this is a bug or is there something wrong with my settings. Does anyone know how I could fix this? For smaller use-cases I can still manually enter the command in the terminal. But I am trying to debug a ROS application with nearly 10 different terminals opening up and I cannot be manually entering the command each time to restart the process.
Please let me know if you need any more information. Many thanks in advance.
Edit: both edits to frame the question properly.
Although not related to WSL, I dug a little deeper today as to why in my case the extension commands were not being executed or were being chopped.
I'm an iTerm2 user. iTerm2 has something called Shell Integrations, which allow iTerm to behave differently under certain circumstances, for example, adding markers to each prompt or coloring output with certain text (e.g. WARNING or ERROR)
From time to time, I also use the VSCode Integrated Terminal, which recently added support for reporting whether the previous command errored out with an indicator on the gutter of the Integrated Terminal panel using the exit code.
iTerm can do something similar but the shell integrations mess up completely the VSCode functionality and therefore I changed my .bashrc file to detect if the terminal emulator was iTerm2 or not (which can be done with the it2check utility of iTerm2) so that it only sourced the shell integrations if I was using iTerm2.
The problem is that it2check "eats" some STDIN bytes using dd, specifically, until it finds an n so that it can obtain the name of the emulator. This of course chops the commands on the STDIN until the first n and makes VSCode Extension Terminal commands unusable
The workaround I came up with is to use the value of "$TERM_PROGRAM" as means to distinguish between the different programs. The only caveat is that the value won't be passed if you're inside of a tmux session or similar, but I can live with that.
In your case, I'd check for any process that is either not passing the STDIN to the WSL process or any dot files or shell profile scripts eating up the STDIN they receive.
I suspect that the real problem is that the local process doesn't relay the STDIN contents to the WSL and as a workaround you may try to create a VSCode Integrated Terminal profile that uses SSH to connect to the WSL host so that the STDIN is preserved

Resize the terminal in vscode is trigger the ctrl+c to terminate the running command

I'm running the vscode 1.64.2 on Windows 10. Currently i met a strange problem, When i resize the terminal in the vscode and the cursor is focus on the terminal, Then it will trigger ctrl+c . At this time any running command would be terminated immediately .
To avoid this i have to un-focus for the terminal first and then resize it. Any suggestion here?
I was searching about this with no luck. Today I realized about one installed software on my machine that has a global hook on mouse selection. In my case was the QTranslate software. When I exit the application the problem was solved.
Check if you have this or another software that has a global hook on mouse selection.
In VS Code this problem (control C) was happening for any command line inside the terminal. Apart from that, opening Git bash (standalone) I was having the same issue, but not for cmd or another command line.
Hope this helps you because this was driving me crazy.
Absolutely working solution!
I experienced the same problem with mouse strange behavior for a long time, but finally I found out it was the QTranslate's guilt! After I stopped it, the problem has gone. (can't vote up because of my virgin profile here).
PS: I found the solution how to push work both QTranslate and terminal window - just set QTranslate setting "Advanced->Copy action" to "Ctrl+Insert" instead of Ctrl+C.

VSCode launches wsl.exe processes which are not terminated after VSCode is closed

Lately, after I have been using VSCode for some time, opening and closing it repeatedly, I was surprised to see, in Process Explorer, a lot of wsl.exe processes. As it looks, 4 or 5 processes were started by VSCode each time I opened it, but were not terminating when I was closing VSCode, so I ended up with a lot of them (there are only 5 in the image, but actually there were several dozens).
I think this has something to do with the following dialog box I see (almost?) every time I open VSCode
(which I was just closing since I am not interested to install these extensions).
Does someone know how to disable the launching of these processes? I had a Docker extension which I uninstalled, but this behavior persists.
Ok, so the culprit is not this something which launches the dialog box (I still see it), but it appears to be the following setting (when checked)
After unchecking it, I don't see now any wsl.exe processes launched when I start VSCode.

VS Code Terminal Not Allowing Typing

My VS code terminal was working fine, until one day when I tried to work on a project, that was still open in VS code, my terminal didn't allow me to type any commands. I couldn't type anything. This is the screen that I get.
Okay, for those of you struggling with the same problem, I've managed to solve it by clicking on the drop-down menu that says powershell and changing it to cmd.
this happened to me and simply
close vs code
right click on it
run as administrator
open the terminal and it will work
this problem happened when I changed the default path of CMD
For me, I tried using Powershell/CMD/Bash and I was having errors/blank terminal. I found typing echo hello and pressing CTRL + C made it appear. So in fact, everything was working, my terminal was just blank/glitched out, but was really accepting input.
I had a similar issue when running ionic serve command which runs the development server on the localhost. I paid attention after executing the command above, and it said:
Use Ctrl+C to quit this process
Pressing Ctrl+C then displays:
Terminate batch job (Y/N)?
Type Y or y
then the command prompt is shown again!
Here is a sample terminal window - trimmed for brevity:
For who has this problem using React. This happens when you start a live version using npm start. The terminal that handles the live version of the app cannot be used for anything else.
So to continue using the terminal you need to open a new terminal to use in parallel. To do so just click on the plus icon in the top right corner of the terminal panel then choose the "Power Shell" option. This will open a new terminal without restarting visual studio.
In Mac, when working with Python, this helped me: instead of clicking on the "Run Code" option, click on "Run Python file", in the right corner.
For Ubuntu users this is solved by this solution:
File -> Preferences -> Setting -> Features -> Terminal -> Inherit Env
I found two vscode on my desktop, I opened the other one and it worked. Looks like I updated it but the older one didn't disappear.
If typing Ctrl+C can help to get out of this frozen state, that will be easier to do with VSCode 1.64 (Jan. 2022)
The terminal can type the answer for you.
Terminal -- Auto-reply
The terminal is now able to automatically reply when a specific sequences of characters is received.
A good example of where this is useful, which is also the only default case, is the Windows batch script message Terminate batch job (Y/N)? after hitting Ctrl+C when running a batch script.
This typically just ends up causing problems for the user.
The terminal will now automatically reply with Y and enter (\r) which makes Ctrl+C in Windows feel much better.
Pressing Ctrl+C will immediately reply to the question and return to the prompt:
Theme: Sapphire
The feature was made generically so you can setup custom replies for other thing, just be careful when doing this as you are sending text to the process automatically.
For example you could use it to automatically update Oh My Zsh when prompted:
"terminal.integrated.autoReplies": {
"[Oh My Zsh] Would you like to check for updates? [Y/n]": "Y\r"
}
If you use Clink and enable their similar feature, you can disable it in Clink or in VS Code by setting the reply to null to avoid the two features conflicting with each other:
"terminal.integrated.autoReplies": {
"Terminate batch job (Y/N)": null
}
Go to terminal, preferences, settings.
Check "run code in terminal"
Restart VS.
I changed from bash to powershell in terminal first but the command prompt still not shown.
Then I navigate to File -> Perferences -> Settings and it starts working (command prompt shown)
This seems to just be a display problem. It happened to me when I changed my display settings for desktop icon and app scaling settings.
I managed to fix the problem by simply restarting my computer and re-opening VS code
I had the same problem ... In my case just run vs-code as administrator and works