OpenQuizz
Une application de gestion des contenus pédagogiques
|
Public Member Functions | |
def | __init__ (self, *args, **kwargs) |
def | finish (self) |
def | handle_sigint (self, signum, frame) |
Data Fields | |
original_handler | |
Helper to ensure that self.finish() gets called on keyboard interrupt. This allows downloads to be interrupted without leaving temporary state (like hidden cursors) behind. This class is similar to the progress library's existing SigIntMixin helper, but as of version 1.2, that helper has the following problems: 1. It calls sys.exit(). 2. It discards the existing SIGINT handler completely. 3. It leaves its own handler in place even after an uninterrupted finish, which will have unexpected delayed effects if the user triggers an unrelated keyboard interrupt some time after a progress-displaying download has already completed, for example.
def __init__ | ( | self, | |
* | args, | ||
** | kwargs | ||
) |
Save the original SIGINT handler for later.
def finish | ( | self | ) |
Restore the original SIGINT handler after finishing. This should happen regardless of whether the progress display finishes normally, or gets interrupted.
def handle_sigint | ( | self, | |
signum, | |||
frame | |||
) |
Call self.finish() before delegating to the original SIGINT handler. This handler should only be in place while the progress display is active.
original_handler |