Re: Shutting down a cross-platform multithreaded app

2015-09-19 Thread Chris Angelico
On Sat, Sep 19, 2015 at 8:48 PM, James Harris wrote: > "Chris Angelico" wrote in message > news:mailman.13.1442657702.21674.python-l...@python.org... >> >> On Sat, Sep 19, 2015 at 7:49 PM, James Harris >> wrote: >>> >>> "Chris Angelico" wrote in message >>> news:mailman.8.1442612439.21674.pytho

Re: Shutting down a cross-platform multithreaded app

2015-09-19 Thread James Harris
"Chris Angelico" wrote in message news:mailman.13.1442657702.21674.python-l...@python.org... On Sat, Sep 19, 2015 at 7:49 PM, James Harris wrote: "Chris Angelico" wrote in message news:mailman.8.1442612439.21674.python-l...@python.org... ... If you're using select() to monitor the sockets

Re: Shutting down a cross-platform multithreaded app

2015-09-19 Thread Chris Angelico
On Sat, Sep 19, 2015 at 7:49 PM, James Harris wrote: > "Chris Angelico" wrote in message > news:mailman.8.1442612439.21674.python-l...@python.org... >> >> On Sat, Sep 19, 2015 at 3:17 AM, James Harris >> wrote: >>> >>> Needless to say, on a test Windows machine AF_UNIX is not present. The >>> on

Re: Shutting down a cross-platform multithreaded app

2015-09-19 Thread James Harris
"Laura Creighton" wrote in message news:mailman.5.1442609448.21674.python-l...@python.org... In a message of Fri, 18 Sep 2015 20:09:19 +0100, "James Harris" writes: Set the daemon flag on the worker threads, so when the main thread exits, the workers also exit. Interesting idea, and I did n

Re: Shutting down a cross-platform multithreaded app

2015-09-19 Thread James Harris
"Chris Angelico" wrote in message news:mailman.8.1442612439.21674.python-l...@python.org... On Sat, Sep 19, 2015 at 3:17 AM, James Harris wrote: Needless to say, on a test Windows machine AF_UNIX is not present. The only cross-platform option, therefore, seems to be to use each subthread's se

Re: Shutting down a cross-platform multithreaded app

2015-09-18 Thread Akira Li
"James Harris" writes: ... > Needless to say, on a test Windows machine AF_UNIX is not present. The > only cross-platform option, therefore, seems to be to use each > subthread's select()s to monitor two AF_INET sockets: the one to the > client and a control one from the master thread. I would se

Re: Shutting down a cross-platform multithreaded app

2015-09-18 Thread Chris Angelico
On Sat, Sep 19, 2015 at 7:48 AM, Random832 wrote: > On Fri, Sep 18, 2015, at 17:40, Chris Angelico wrote: >> Bear in mind, though, that Windows has no protection against other >> processes shutting you down. > > Neither does Unix. Any process that can send you a signal can send you > SIGKILL. Inc

Re: Shutting down a cross-platform multithreaded app

2015-09-18 Thread Random832
On Fri, Sep 18, 2015, at 17:40, Chris Angelico wrote: > Bear in mind, though, that Windows has no protection against other > processes shutting you down. Neither does Unix. Any process that can send you a signal can send you SIGKILL. Of course, what Windows lacks is a generalized way for other pr

Re: Shutting down a cross-platform multithreaded app

2015-09-18 Thread Chris Angelico
On Sat, Sep 19, 2015 at 3:17 AM, James Harris wrote: > Needless to say, on a test Windows machine AF_UNIX is not present. The only > cross-platform option, therefore, seems to be to use each subthread's > select()s to monitor two AF_INET sockets: the one to the client and a > control one from the

Re: Shutting down a cross-platform multithreaded app

2015-09-18 Thread Laura Creighton
In a message of Fri, 18 Sep 2015 20:09:19 +0100, "James Harris" writes: >> Set the daemon flag on the worker threads, so when the main thread >> exits, the workers also exit. > >Interesting idea, and I did not know that a *thread* could be a daemon. >Unfortunately, I think what you suggest would k

Re: Shutting down a cross-platform multithreaded app

2015-09-18 Thread Marko Rauhamaa
"James Harris" : > I have a multithreaded app that I want to be able to shut down easily > such as by hitting control-c or sending it a signal. The problem with threads is you cannot cause them to exit from the outside. You can do that to asyncio coroutines, however. Maybe you should consider por

Re: Shutting down a cross-platform multithreaded app

2015-09-18 Thread James Harris
"Paul Rubin" wrote in message news:87zj0jd1ta@jester.gateway.sonic.net... "James Harris" writes: I have a multithreaded app that I want to be able to shut down easily such as by hitting control-c or sending it a signal. Set the daemon flag on the worker threads, so when the main thre

Re: Shutting down a cross-platform multithreaded app

2015-09-18 Thread Paul Rubin
"James Harris" writes: > I have a multithreaded app that I want to be able to shut down easily > such as by hitting control-c or sending it a signal. Set the daemon flag on the worker threads, so when the main thread exits, the workers also exit. -- https://mail.python.org/mailman/listinfo/pyt

Shutting down a cross-platform multithreaded app

2015-09-18 Thread James Harris
Well, this is fun ... for some definition of the word. ;-( I have a multithreaded app that I want to be able to shut down easily such as by hitting control-c or sending it a signal. What follows is the way I have come up with given the common elements of different environments. Suggestions for