Interrupting Scan Macros by Ctrl-C (pre_scan_hook fixup)

Scan Macros can be interrupted by Ctrl-Cs. Sardana behaves differently depending on the number of Ctrl-Cs pressed. Single and double Ctrl-Cs do not require any fix-up procedure. However, triple Ctrl-Cs need a special treatment. But they are needed, if the sample time is too long to wait for the completion of even a single cycle.

Note: SardanaRestartBoth3.py -x resolves all issues related to Ctrl-Cs. But this requires human intervention and it takes time. The purpose of this section is to explain how the brute force method can be avoided. Below you find a pre_scan_hook which can automatically be executed and which brings Sardana back to an operational state after multiple Ctrl-Cs have been pressed.