Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #96295

Re: Signal SIGINT ignored during socket.accept

References <msshpm$7pn$1@dont-email.me> <mailman.332.1441910212.8327.python-list@python.org> <msskh1$j00$1@dont-email.me>
Date 2015-09-11 05:26 +1000
Subject Re: Signal SIGINT ignored during socket.accept
From Chris Angelico <rosuav@gmail.com>
Newsgroups comp.lang.python
Message-ID <mailman.337.1441913195.8327.python-list@python.org> (permalink)

Show all headers | View raw


On Fri, Sep 11, 2015 at 5:11 AM, James Harris <james.harris.1@gmail.com> wrote:
> S:\>python socktest.py
> Traceback (most recent call last):
>  File "socktest.py", line 6, in <module>
>    endpoint = s.accept()
>  File "C:\Python27\lib\socket.py", line 202, in accept
>    sock, addr = self._sock.accept()
> KeyboardInterrupt
>
> S:\>
>
> However, on Windows the recognition of Control-C does not happen until after
> something connects to the socket.
>
> I will carry on researching it but maybe the above gives a clue to those in
> the know...!

This is a known problem on Windows. I can't remember what the best
solution was, but there's a chance something got into 2.7.10, as it
was fairly recent. There's a significantly better chance that
something's different in Python 3.x. You may find it worth grabbing a
few different versions of Python and trying the same code on all of
them.

You may run into issues with XP, though. For instance, Python 3.5
doesn't support it, and (IIRC) won't install at all; 3.4 does work, as
will all releases of 2.7.x. Worst case, grab yourself a Windows 7 and
try a few tests.

But a quick test on one of my VMs, with 3.4 on Win 7, didn't show any
change. It's entirely possible that a blocking socket-accept call will
continue to block. There is one rather silly option, and that's to use
select() to effectively poll for Ctrl-C... or, possibly better, have a
separate program that shuts down your server (by connecting to it,
which thus breaks the stranglehold).

Of course, switching over to Unix is also a good option...

ChrisA

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Signal SIGINT ignored during socket.accept "James Harris" <james.harris.1@gmail.com> - 2015-09-10 19:24 +0100
  Re: Signal SIGINT ignored during socket.accept Chris Angelico <rosuav@gmail.com> - 2015-09-11 04:36 +1000
    Re: Signal SIGINT ignored during socket.accept "James Harris" <james.harris.1@gmail.com> - 2015-09-10 20:11 +0100
      Re: Signal SIGINT ignored during socket.accept Chris Angelico <rosuav@gmail.com> - 2015-09-11 05:26 +1000
        Re: Signal SIGINT ignored during socket.accept "James Harris" <james.harris.1@gmail.com> - 2015-09-10 21:12 +0100
          Re: Signal SIGINT ignored during socket.accept Chris Angelico <rosuav@gmail.com> - 2015-09-11 12:01 +1000
            Re: Signal SIGINT ignored during socket.accept Grant Edwards <invalid@invalid.invalid> - 2015-09-11 13:50 +0000
              Re: Signal SIGINT ignored during socket.accept Marko Rauhamaa <marko@pacujo.net> - 2015-09-11 17:00 +0300
              Re: Signal SIGINT ignored during socket.accept Chris Angelico <rosuav@gmail.com> - 2015-09-12 00:27 +1000
              Re: Signal SIGINT ignored during socket.accept "James Harris" <james.harris.1@gmail.com> - 2015-09-11 18:14 +0100
                Re: Signal SIGINT ignored during socket.accept "James Harris" <james.harris.1@gmail.com> - 2015-09-12 00:15 +0100

csiph-web