Re: How to shut down a TCPServer serve_forever() loop?

2017-11-28 Thread Ian Kelly
On Tue, Nov 28, 2017 at 11:54 AM, Marko Rauhamaa wrote: > Chris Angelico : >> Would the OP have been trivially able to send a signal to the >> process? Yes. > >Python signal handlers are always executed in the main Python thread, >even if the signal was received in another thread. This mea

Re: How to shut down a TCPServer serve_forever() loop?

2017-11-28 Thread Marko Rauhamaa
Chris Angelico : > On Wed, Nov 29, 2017 at 5:32 AM, Marko Rauhamaa wrote: >> Don't you worry about my programs. > > Okay, but you can't claim that problems are solvable if you cheat them. What I'm saying is that there's no particular reason why glibc couldn't offer a solution. There *is* getaddri

Re: How to shut down a TCPServer serve_forever() loop?

2017-11-28 Thread Chris Angelico
On Wed, Nov 29, 2017 at 5:32 AM, Marko Rauhamaa wrote: > Chris Angelico : > >> On Wed, Nov 29, 2017 at 5:03 AM, Marko Rauhamaa wrote: >>> Chris Angelico : Do you respect /etc/nsswitch.conf? >>> >>> No, but I don't need to. >> >> Ah, right. Until the day you're wrestling with "why doesn't /et

Re: How to shut down a TCPServer serve_forever() loop?

2017-11-28 Thread Marko Rauhamaa
Chris Angelico : > On Wed, Nov 29, 2017 at 5:03 AM, Marko Rauhamaa wrote: >> Chris Angelico : >>> Do you respect /etc/nsswitch.conf? >> >> No, but I don't need to. > > Ah, right. Until the day you're wrestling with "why doesn't /etc/hosts > apply to this program". Yep, you totally don't need nssw

Re: How to shut down a TCPServer serve_forever() loop?

2017-11-28 Thread Chris Angelico
On Wed, Nov 29, 2017 at 5:03 AM, Marko Rauhamaa wrote: > Chris Angelico : > >> On Wed, Nov 29, 2017 at 4:22 AM, Marko Rauhamaa wrote: >>> I have solved the gethostbyname() problem by implementing the DNS >>> protocol myself (in Python). >> >> Do you respect /etc/nsswitch.conf? > > No, but I don't

Re: How to shut down a TCPServer serve_forever() loop?

2017-11-28 Thread Marko Rauhamaa
Chris Angelico : > On Wed, Nov 29, 2017 at 4:22 AM, Marko Rauhamaa wrote: >> I have solved the gethostbyname() problem by implementing the DNS >> protocol myself (in Python). > > Do you respect /etc/nsswitch.conf? No, but I don't need to. >>> I don't understand why you keep insisting that async

Re: How to shut down a TCPServer serve_forever() loop?

2017-11-28 Thread Chris Angelico
On Wed, Nov 29, 2017 at 4:22 AM, Marko Rauhamaa wrote: > I have solved the gethostbyname() problem by implementing the DNS > protocol myself (in Python). Do you respect /etc/nsswitch.conf? >> I don't understand why you keep insisting that asyncio and threads are >> somehow incompatible, > > Wher

Re: How to shut down a TCPServer serve_forever() loop?

2017-11-28 Thread Marko Rauhamaa
Chris Angelico : > On Tue, Nov 28, 2017 at 11:52 PM, Marko Rauhamaa wrote: >> The original poster's problem seems to be caused by blocking APIs that >> cannot be multiplexed using select(). A good many Python facilities are >> the same way. >> >> Such blocknoxious APIs are at the core of the mult

Re: How to shut down a TCPServer serve_forever() loop?

2017-11-28 Thread Chris Angelico
On Tue, Nov 28, 2017 at 11:52 PM, Marko Rauhamaa wrote: > Chris Angelico : > >> On Tue, Nov 28, 2017 at 5:04 PM, Marko Rauhamaa wrote: >>> Seems to be one of the fundamental multithreading issues: each thread >>> is blocked on precisely one event. Asyncio is more flexible: you can >>> multiplex o

Re: How to shut down a TCPServer serve_forever() loop?

2017-11-28 Thread Marko Rauhamaa
Chris Angelico : > On Tue, Nov 28, 2017 at 5:04 PM, Marko Rauhamaa wrote: >> Seems to be one of the fundamental multithreading issues: each thread >> is blocked on precisely one event. Asyncio is more flexible: you can >> multiplex on a number of events. > > Not really, no. Unless select() counts

Re: How to shut down a TCPServer serve_forever() loop?

2017-11-28 Thread Chris Angelico
On Tue, Nov 28, 2017 at 5:04 PM, Marko Rauhamaa wrote: > Ian Kelly : > >> On Sat, Nov 25, 2017 at 7:10 AM, John Pote >> wrote: >>> The issue is that if I press a key on the keyboard the key is >>> immediately shown on the screen but then the shutdown() call blocks >>> until another TCP connectio

Re: How to shut down a TCPServer serve_forever() loop?

2017-11-27 Thread Marko Rauhamaa
Ian Kelly : > On Sat, Nov 25, 2017 at 7:10 AM, John Pote wrote: >> The issue is that if I press a key on the keyboard the key is >> immediately shown on the screen but then the shutdown() call blocks >> until another TCP connection is made, text is echoed back and only >> then does serve_forever(

Re: How to shut down a TCPServer serve_forever() loop?

2017-11-27 Thread Ian Kelly
On Sat, Nov 25, 2017 at 7:10 AM, John Pote wrote: > Hi all, > > My problem in summary is that my use of the shutdown() method only shuts > down a server after the next TCP request is received. > > I have a TCP server created in the run() method of a thread. > > class TCPlistener( Thread ): >

How to shut down a TCPServer serve_forever() loop?

2017-11-25 Thread John Pote
Hi all, My problem in summary is that my use of the shutdown() method only shuts down a server after the next TCP request is received. I have a TCP server created in the run() method of a thread.     class TCPlistener( Thread ):         def run( self ):       with socketserver.TCPServer(