I would like to know if any python script is terminated in the middle due to powerloss or some other stuff,Can the python script be restarted where it left?.
Is it possible anyhow that the script restarts from only where the code has not been executed.
THANKS.
Related
there may very well be an answer to this question, but it's really hard to google for.
you can add commands to gdb by writing them in python. I am interested in debugging one of those python scripts that's running in gdb session.
my best guess is to run gdb on gdb and execute the user added command and somehow magically break on the python program code?
has anybody done anything like this before? I don't know the mechanism by which gdb calls python code, so if it's not in the same process space as the gdb that's calling it, I don't see how I'd be able to set breakpoints in the python program.
or do I somehow get pdb to run in gdb? I guess I can put pdb.set_trace() in the python program, but here's the extra catch: I'd like to be able to do all this from vscode.
so I guess my question is: what order of what things do I need to run to be able to vscode debug a python script that was initiated by gdb?
anybody have any idea?
thanks.
so I figured it out. it's kinda neat.
you run gdb to debug your program as normal, then in another window you attach to a running python program.
in this case the running python program is the gdb process.
once you attach, you can set breakpoints in the python program, and then when you run commands in the first window where the gdb session is, if it hits a breakpoint in the python code, it will pop up in the second window.
the tipoff was that when you run gdb there does not appear to be any other python process that's a child of gdb or related anywhere, so I figured gdb must dynamically link to some python library so that the python compiler/interpreter must be running in the gdb process space, so I figured I'd try attaching to that, and it worked.
I've started running a Python script that takes about 3 days to finish. My understanding is that Linux processes make a copy of a python script at the time they're created, so further edits on the file won't impact the running process.
However, I just realized I've made a mistake on the code and the processes running for over 2 days are going to crash. Is it possible to edit the copy of the python script the process loaded?
I'm basically trying to figure out if there's a way to fix the mistake I've made without having to restart the script execution.
No, you can't. The interpreter byte compiles your source code when it initially reads it. Updating the file won't change the byte code that is running.
What to do when the python debugger seems to get stuck after running the first few (five) lines of code?
I have been using Python for quite a while, but starting yesterday, I have not been able to use the debugger. Whenever i try to run the debugger, it just displays the first 5 lines of the script and then stops.
If I then try to exit out of the debugger, it just displayer --KeyboardInterrupt-- but it does not terminate the process.
I am running Python 3.9 with Spyder, and have tried fixing it by restarting, resetting to factory setting, installing into a new environment, as well as a total uninstall and clear, and then installing from scratch, but nothing seems to work.
Even when i try running really basic scripts (like the images below) the result is the same
Running basic scripts normally (F5) works fine
But debugging just gets stuck
And terminating the debugger process is not possible
I have in my case Jenkins job which has building script in its configuration. Inside that script I am running parameterized Python script. At the end of python script I am running parameterized bash .sh script. Problem is, that eventhough it is in code at the end it is running actually on the very begining of python script, and haven't been ran at the place where it supposed to be. I was usign osRun, os.system, subprocess in order to run bash script inside python but the result is the same. Does anyone have a clue where to look for an error.
I am writing a script in python and I would like to stop the scipt in the middle to see the objects and things. I used sys.exit() in pyscripter and everything is fine, but when I switch to spyder, the python interpreter is killed and I cannot read anything after the script is stopped.
How to fix it?