On a linux system (tried two debian based ones) I would like to send user signals to a python application.
I find that the following code (adopted from a different stack exchange question) works as expected with python 2.7, but throws an error with python 3.5
#!/usr/bin/python
import signal
import os
import time
def receive_signal(signum, stack):
print('Received:', signum)
signal.signal(signal.SIGUSR1, receive_signal)
signal.signal(signal.SIGUSR2, receive_signal)
print('My PID is:', os.getpid())
while True:
print('Waiting...')
time.sleep(3)
In latter case the error I get reads
Traceback (most recent call last):
File "[...]/signal.py", line 3, in <module>
import signal
File "[...]/signal.py", line 10, in <module>
signal.signal(signal.SIGUSR1, receive_signal)
AttributeError: module 'signal' has no attribute 'SIGUSR1
I cannot seem to find information about it. Has the name been deprecated?