Python - Trap all signals

前端 未结 8 1481
慢半拍i
慢半拍i 2020-11-30 04:54

In python 2.6 under Linux, I can use the following to handle a TERM signal:

import signal
def handleSigTERM():
    shutdown()
signal.signal(signal.SIGTERM, h         


        
8条回答
  •  感动是毒
    2020-11-30 05:15

    In Python3.8 we've got a new function signal.valid_signals() https://docs.python.org/3/library/signal.html#signal.valid_signals

    import signal
    for sig in signal.valid_signals():
        print(f"{sig:2d}",sig)
    

提交回复
热议问题