FAQ

On Fri, Sep 11, 2015 at 4:24 AM, James Harris wrote:
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.

What version of Python are you using? Also (in case it matters), what
version of Windows?


Have you tested on any Unix system? I just tried on my Linux, and
Ctrl-C interrupted the accept() straight away, so this is quite
probably a Windows-only issue.


Can you produce an absolute minimal demo program? I'd try something like this:


import socket
s = socket.socket()
s.listen(1)
s.accept()


which is what worked for me (interactively, Python 2.7.9 and 3.6.0a0,
Debian Linux).


ChrisA

Search Discussions

Discussion Posts

Previous

Follow ups

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 2 of 11 | next ›
Discussion Overview
grouppython-list @
categoriespython
postedSep 10, '15 at 6:24p
activeSep 11, '15 at 11:15p
posts11
users4
websitepython.org

People

Translate

site design / logo © 2017 Grokbase