title: How to use more arguments with signal-handler?
body: <p>Python restricts the signal handler functions ( handling SIGINT, SIGTERM et..) to the following signature with no option to pass extra arguments.</p>
  <pre><code>def signal_handler(sig, frame):
  </code></pre>
  <p><strong>In the following scenario</strong> when the program consists of multiple processes, I would like to terminate the  the processes gracefully in a staggered fashion upon receiving a termination signal.</p>
  <p><strong>The problem</strong> is when trying to pass the shutdown events and processes to the signal handler, the only way I managed to do so is via using globals.</p>
  <p><strong>My question is</strong>: In this scenario, how can one avoid using globals?</p>
  <pre><code># shutdown events for graceful termination
  taskhandler_shutdown = Event()
  logger_shutdown = Event()
  
  # start the processes
  p_taskhandler = Process(target=taskhandler.capture, args=[taskhandler_shutdown])
  p_taskhandler.start()
  p_eventlogger = Process(target=eventlogger.capture, args=[logger_shutdown])
  p_eventlogger.start()
  
  
  def termination_signal_handler(sig, frame):
  
      # staggered shutdown, first terminate taskhandler
      taskhandler_shutdown.set()
      p_taskhandler.join()
  
      # now terminate logger process
      logger_shutdown.set()
      p_eventlogger.join()
  
      sys.exit(0)
  
  </code></pre>