I'm working with a fairly large dataset and any time I perform an operation, if I forget to include the semi-colon at the end of the statement it takes several minutes because it outputs all the data to the console window as it goes. How do I halt execution of the current statement?
I've tried using Ctrl-C like in MATLAB, as well as using the Abort and Interrupt options in the Control menu, none of which seem to be working. Is this a bug, or am I missing something? I'm running on Windows 8 64-bit in case that helps.
To halt execution, press Ctrl-C in the console window of Scilab. This will display
Type 'resume' or 'abort' to return to standard level prompt.
-1->
Entering abort abandons the computation completely. Entering resume resumes it.
I did not check it but this tutorial gives as option the ESC key
"To abort a command midway without executing it, press the Esc key on the keyboard."
Related
There is this answer for python from an old thread which I used in the past to great effect (see first answer here How to prevent a block of code from being interrupted by KeyboardInterrupt in Python?). I'd like to know if it is possible to do something similar in Julia.
That's pretty much it, but here's some background.
I'm developing a Markov Chain Monte Carlo algorithm in Julia and I need to insure that the state of the chain is always valid, especially following a Ctrl+C/SIGINT. This is particularly important during development in the REPL where I want to be able to stop the chain but then restart it where it was left off without having to start from scratch and wait for the burn-in period all over again.
As it stand it is almost always the case that the chain will be in an invalid state following a SIGINT.
In other words I want to have blocks of code that are uninterruptibles, namely critical blocks within which a SIGINT is deferred until the block has terminated.
Ctrl+C/SIGINT causes the InterruptException, so you can place your code within a try block and catch the InterruptException.
try
# ... your algorithm here ...
catch e
if e isa InterruptException
save_your_chain_to_a_valid_state()
then_exit()
else
rethrow()
end
end
If you're running the code outside of the REPL, you'll first have to call Base.exit_on_sigint(false) before the try block.
disable_sigint prevents a block of code to be interrupted immediately, whereas catching InterruptException is a mean to handle the interrupt:
try
disable_sigint() do
for i in 1:5
sleep(1)
print(".")
end
end
println("\nnow it is safe to interrupt immediately")
while true
sleep(1)
print("*")
end
catch InterruptException
println("interrupt catched")
end
If running a script remember how to catch Ctrl-C:
julia -e 'include(pop!(ARGS))' script.jl
disable_sigint is able to mask the InterruptException generated by a SIGINT signal (for example a signal coming from a
kill command on unix). For example if the running code is notified throwing directly an interruptException() it is interrupted as soon as possible ignoring the disable_sigint directive.
This may be the case of a jupyter environment where communication between client and kernel processes happens through a IPC channel (ZeroMQ transport channel) or the case of vscode where a "supervisor" process manage a child julia execution context.
Chances are that the kernel interrupt command delivered from jupiter frontend to jupyter kernel backend that "supervises" julia code is not delivered to child process using a SIGINT OS-signal.
What does In [*] at the upper left-hand of the cell mean when running a Jupyter notebook?
I know that when the cell in Jupyter notebook has not been run, it shows as In[ ], after running the cell, it shows as In[num].
What about In [*], does it mean that this cell is running now?
This means that your kernel is busy.
If you want to interrupt/stop the execution, go to the menu Kernel and click Interrupt.If it doesn't work, click Restart.
You need to go in a new cell and press Shift + Enter to see if it worked.
When a cell is displayed as "busy" with an asterisk, it can mean one of several things:
The cell is currently executing.
An "execute" command was sent to the cell, but another cell is currently executing. The cell will execute when its turn comes.
The kernel was interrupted / restarted while the cell was executing, it is currently not executing.
it would mean that either your code timed out or ran out of memory,
Check for infinite loops or memory leaks.
When a cell is displayed with an asterisk it means it's busy.
It might mean that: 1) The cell is now executing; 2)or it will execute when it's turn arrives. 3)or it is not executing because the kernel was restarted or interrupted.
My recommendation is that you save the file and restart the kernell in preferrence without running everything, but if you are sure everything can run without problems just do it and it will be faster for you.
Is there a way to detect whether execution is currently in the middle of QDialog.exec()?
I'm the author of DreamPie, a Python shell, and it lets you run Python code while Qt GUI is being displayed. It does that by running the Qt event loop for 1/10 of a second, and then checking if any Python commands need to be executed. The event loop is stopped by a QTimer which calls QApplication.quit() after the timeout.
If a QDialog.exec() is active, however, I don't want to call QApplication.quit(), because it will break the code. The current solution is to check whether there's a modal dialog active, by checking if QApplication.activeModalWidget() is None. However, I currently have a modal dialog which is not run with QDialog.exec(), and it's blocking Python commands for no reason.
Is there a way to exit the event loop only if it's not called recursively by QDialog.exec()?
Thanks!
You can check whether your dialog is visible with QDialog.isVisible. Normally, a modal dialog is visible only while it is being executed.
I've written a short script (in another language, happens to be Python) which passes arguments to the command line as follows -
ildrt <path/filename.sav> -args p1 p2 --o1 --o2
where p, o are positional and optional arguments respectively (obvious). To get to the point, this script calls an IDL routine any number of times. Each time, the IDL virtual machine is loaded, the IDL routine runs until completion, rinse and repeat.
Unfortunately if an error occurs in the IDL routine execution a dialog box will popup and halt program execution until manually clicked. Since the idea is to run this as a batch process I want to ignore the dialog boxes, (accepting the error), and continue to the next run. Any thoughts on preferences or optional commands I can run IDL with to prevent the popups? Thanks in advance.
I guess I'm not following. Can't you just pass a flag to your program and then check that flag before popping up a dialog in your code? If you don't have access to the .pro code, then I don't think you can prevent the popups.
I'm currently writing a macro that performs a series of control sends and control clicks.
They must be done in the exact order.
At first I didn't have any sleep statements, so the script would just go through each command regardless whether the previous has finished or not (ie: click SUBMIT before finish sending the input string)
So I thought maybe I'll just put some sleep statements, but then I have to figure out how best to optimize it, AND I have to consider whether others' computers' speeds because a slow computer would need to have longer delays between commands. That would be impossible to optimize for everyone.
I was hoping there was a way to force each line to be run only after the previous has finished?
EDIT: To be more specific, I want the controlsend command to finish executing before I click the buttons.
Instead of ControlSend, use ControlSetText. This is immediate (like GuiEdit).
My solution: use functions from the user-defined library "GuiEdit" to directly set the value of the textbox. It appears to be immediate, thus allowing me to avoid having to wait for the keystrokes to be sent.