breilly / fm-orchestrator

Forked from fm-orchestrator 4 years ago
Clone

0d0d809 test_build: leave Control-C working

Authored and Committed by otaylor 2 years ago
    test_build: leave Control-C working
    
    Two problems occurred with the moksha/twisted handling of SIGINT:
    
     * While KeyboardInterrupt caused the moksha loop to exit, it just
       left the test in a confused state, instead of triggering standard
       pytest behavior and aborting the entire test run.
     * The handler was left-over for remaining tests that prevent Control-C
       from working at all.
    
    Fix that by using mock.patch to override moksha's signal handler with
    our own signal handler that stores the KeyboardInterrupt in the
    current EventTrap, and restores the default signal handler after
    the loop ends.
    
    Note that since the KeyboardInterrupt is always handled in the main thread,
    we don't get a useful backtrace from the child thread.
    
        
file modified
+36 -18