• Kirill Smelkov's avatar
    Nogil signals · e18adbab
    Kirill Smelkov authored
    Provide os/signal package that can be used to setup signal delivery to nogil
    channels. This way for user code signal handling becomes regular handling of a
    signalling channel instead of being something special or limited to only-main
    python thread. The rationale for why we need it is explained below:
    
    There are several problems with regular python's stdlib signal module:
    
    1. Python2 does not call signal handler from under blocked lock.acquire.
       This means that if the main thread is blocked waiting on a semaphore,
       signal delivery will be delayed indefinitely, similarly to e.g. problem
       described in nexedi/nxdtest!14 (comment 147527)
       where raising KeyboardInterrupt is delayed after SIGINT for many,
       potentially unbounded, seconds until ~semaphore wait finishes.
    
       Note that Python3 does not have this problem wrt stdlib locks and
       semaphores, but read below for the next point.
    
    2. all pygolang communication operations (channels send/recv, sync.Mut...
    e18adbab
os.cpp 7.42 KB