title: Signal handlers and logging in Python
body: <p><a href="http://docs.python.org/library/logging.html#thread-safety" rel="noreferrer">Documentation for logging module</a> says that</p>
  
  <blockquote>
    <p>If you are implementing asynchronous signal handlers using the signal module, you may not be able to use logging from within such handlers. This is because lock implementations in the threading module are not always re-entrant, and so cannot be invoked from such signal handlers.</p>
  </blockquote>
  
  <p>This suggests that one should not make logging calls from the code invoked by the signal handler directly or indirectly. If you do once in a while program will be left is a state when only kill -9 helps.</p>
  
  <p>Important question for me now is following. Can this locking problem also happen when <em>other threads call logging methods</em> at the time when <em>main thread is processing a signal</em>?</p>