使用signal.pthread_sigmask时的属性错误

时间:2016-05-29 16:37:10

标签: python

每次尝试使用signal.pthread_sigmask

时,我都会收到错误

错误是: AttributeError:' int'对象没有属性' pthread_sigmask'

def clean_up():
        socket.close()
        context.term()

def receive_signal(signal, stack):
        signal.pthread_sigmask(signal.SIG_BLOCK, signal.SIGINT)
        print ("Exiting because I received a signal:", signum)
        clean_up()
        sys.exit(1)

#Create zmq context and bind socket
context = zmq.Context()
socket = context.socket(zmq.REP)
socket.bind("tcp://*:5555")

#Register signal handler with signals
signal.signal(signal.SIGINT, receive_signal)
signal.signal(signal.SIGTERM, receive_signal)
signal.signal(signal.SIGHUP, receive_signal)

1 个答案:

答案 0 :(得分:2)

通过在malloc()函数receive_signal中命名参数,您正在隐藏模块signal,只需将其称为其他内容,您似乎正在使用名为signal的内容那就是你要使用的东西呢?

signum