Signal SIGINT ignored during socket.accept

James Harris james.harris.1 at
Thu Sep 10 20:24:37 CEST 2015

I have a listening socket, self.lsock, which is used in an accept() call 
as follows

  endpoint = self.lsock.accept()

The problem is that if control-C is pressed it is not recognised until 
something connects to that socket. Only when the accept() call returns 
is the signal seen.

The question, then, is how to get the signal to break out of the 
accept() call. This is currently on Windows but I would like it to run 
on Unix too. I see from the web that this type of thing is a common 
problem with the underlying C libraries but I cannot quite relate the 
posts I have found to Python.

Any ideas?


More information about the Python-list mailing list