OpenQuizz
Une application de gestion des contenus pédagogiques
InterruptibleMixin Class Reference
Inheritance diagram for InterruptibleMixin:

Public Member Functions

def __init__ (self, *args, **kwargs)
 
def finish (self)
 
def handle_sigint (self, signum, frame)
 

Data Fields

 original_handler
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ __init__()

def __init__ (   self,
args,
**  kwargs 
)
Save the original SIGINT handler for later.

Member Function Documentation

◆ finish()

def finish (   self)
Restore the original SIGINT handler after finishing.

This should happen regardless of whether the progress display finishes
normally, or gets interrupted.

◆ handle_sigint()

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.

Field Documentation

◆ original_handler

original_handler

The documentation for this class was generated from the following file: