I have a program that block reading with select,but i want it to return gracefully with sending a SIGINT signal. and process that signal with a handler. unfortunately, the block program does not return from select system call, instead it receives SIGINT and interupt. can anybody help me with figuring out what is the problem? thanks a lot.
import select
import socket
import signal
class Test(object):
def __init__(self):
self._read, self._write = socket.socketpair()
def wait(self):
readable = [self._read.fileno()]
return select.select(readable, [], readable)
def wakeup(self):
self._write.send('1')
t = Test()
def handler(signum, frame):
t.wakeup()
signal.signal(signal.SIGINT, handler)
if __name__ == '__main__':
print t.wait()
print 'over.'