-
Notifications
You must be signed in to change notification settings - Fork 20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add @interruptable macro #554
base: master
Are you sure you want to change the base?
Conversation
very cool - and even better than we discussed with the number of final iterations adjustable. i think 1 is good for some algorithms. stupid question: upon ctrl-c is the "remainder" of the loop iteration still correctly executed? I assume yes? @sebastiendesignolle |
Unfortunately no! The macro only has access to the body of the loop as a whole, so the breaking point is unknown. This may indeed lead to unexpected behaviours, but this is probably fine for testing, which is anyway the purpose of this feature. Btw, I've just done a quick performance test and could not see any measurable drawback. |
let's discuss this soon - maybe there is a way to ensure that always "full" loops are executed. |
from the logic it seems that the full loop is completed as you only change the variable interrupted via the exception |
As discussed today, this feature is unfortunately not possible in Julia. Unlike languages with longjmp-style exception handling (like C's setjmp/longjmp or SEH in Windows), Julia's exceptions immediately unwind the stack to the nearest catch. This means that we have no way of going back to the code where the Ctrl-C raised the exception. I've just added a warning, this is ready to merge for me. |
Works like a charm! Scoping was indeed a bit delicate...
In many cases, we could actually skip the extra iteration since everything is recomputed one last time, but there's a argument for that if needed (default to 1 currently).