Exemple #1
0
def stop():
    """
    Stop the main loop and terminate all child processes and named
    threads started via the Kaa API.

    Any notifier callback can also cause the main loop to terminate
    by raising SystemExit.
    """
    global _shutting_down

    if _shutting_down:
        return

    if is_running():
        # loop still running, send system exit
        log.info('Stop notifier loop')
        notifier.shutdown()

    _shutting_down = True
    
    signals["shutdown"].emit()
    signals["shutdown"].disconnect_all()
    signals["step"].disconnect_all()

    # Kill processes _after_ shutdown emits to give callbacks a chance to
    # close them properly.
    supervisor.stopall()

    kill_jobserver()
    # One final attempt to reap any remaining zombies
    try:
        os.waitpid(-1, os.WNOHANG)
    except OSError:
        pass
Exemple #2
0
 def handle(self):
     """
     Callback from the real mainloop.
     """
     try:
         try:
             notifier.step(sleep = False)
         except (KeyboardInterrupt, SystemExit):
             set_mainloop_running(False)
             notifier.shutdown()
     finally:
         self._lock.release()
Exemple #3
0
 def signal_handler(*args):
     # use the preferred stop function for the mainloop. Most
     # backends only call sys.exit(0). Some, like twisted need
     # specific code.
     notifier.shutdown()