Catch SIGHUP from agi in Python?


Has anyone successfully catch a SIGHUP signal when running a python AGI?
I’d like to execute some actions when a user enters the AGI and hangup.
I’m using pyst2. Should I be able to to see the SIGHUP sent to my application when AGI set debug is on?

Part of my Python code to detect hangup
import signal
signal.signal(signal.SIGHUP, signal_handler)

def signal_handler(signal, frame):
print (‘User hangup’)

I’m using asterisk 14.2

The thing that puzzles me, is that once in a while I do catch the SIGHUP event and other time nothing.