Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #96842
| From | Akira Li <4kir4.1i@gmail.com> |
|---|---|
| Subject | Re: Shutting down a cross-platform multithreaded app |
| Date | 2015-09-19 02:56 +0300 |
| References | <mthgrk$uh1$1@dont-email.me> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.12.1442620567.21674.python-list@python.org> (permalink) |
"James Harris" <james.harris.1@gmail.com> 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 seem to need > IP socket pairs between the master thread and the subthreads. If the > master thead receives a shutdown signal it will send a shutdown > command to each subthread. There is socket.socketpair() on Windows too (since Python 3.5) https://docs.python.org/3/library/socket.html#socket.socketpair http://bugs.python.org/issue18643 Note: you could use select() to handle signals in the main thread too (even on Windows since Python 3.5) if you use signal.set_wakeup_fd() https://docs.python.org/3/library/signal.html#signal.set_wakeup_fd It is known as a self-pipe trick http://www.sitepoint.com/the-self-pipe-trick-explained/ Look at *asyncio* source code, to see how to get a portable implementation for various issues with signals. Some issues might still be opened e.g., Ctrl+C behavior http://bugs.python.org/issue24080 Here's how to combine SIGCHLD signal handling with tkinter's event loop http://stackoverflow.com/questions/30087506/event-driven-system-call-in-python SIGCHLD, createfilehandler() are not portable but the code demonstrates possible set_wakeup_fd() issues and their solutions (O_NONBLOCK, dummy signal handler, SA_RESTART, signal coalescing). On threads and signals in CPython http://bugs.python.org/issue5315#msg102829
Back to comp.lang.python | Previous | Next — Previous in thread | Find similar | Unroll thread
Shutting down a cross-platform multithreaded app "James Harris" <james.harris.1@gmail.com> - 2015-09-18 18:17 +0100
Re: Shutting down a cross-platform multithreaded app Paul Rubin <no.email@nospam.invalid> - 2015-09-18 11:23 -0700
Re: Shutting down a cross-platform multithreaded app "James Harris" <james.harris.1@gmail.com> - 2015-09-18 20:09 +0100
Re: Shutting down a cross-platform multithreaded app Laura Creighton <lac@openend.se> - 2015-09-18 22:50 +0200
Re: Shutting down a cross-platform multithreaded app "James Harris" <james.harris.1@gmail.com> - 2015-09-19 10:56 +0100
Re: Shutting down a cross-platform multithreaded app Marko Rauhamaa <marko@pacujo.net> - 2015-09-18 23:40 +0300
Re: Shutting down a cross-platform multithreaded app Chris Angelico <rosuav@gmail.com> - 2015-09-19 07:40 +1000
Re: Shutting down a cross-platform multithreaded app "James Harris" <james.harris.1@gmail.com> - 2015-09-19 10:49 +0100
Re: Shutting down a cross-platform multithreaded app Chris Angelico <rosuav@gmail.com> - 2015-09-19 20:14 +1000
Re: Shutting down a cross-platform multithreaded app "James Harris" <james.harris.1@gmail.com> - 2015-09-19 11:48 +0100
Re: Shutting down a cross-platform multithreaded app Chris Angelico <rosuav@gmail.com> - 2015-09-19 20:59 +1000
Re: Shutting down a cross-platform multithreaded app Random832 <random832@fastmail.com> - 2015-09-18 17:48 -0400
Re: Shutting down a cross-platform multithreaded app Chris Angelico <rosuav@gmail.com> - 2015-09-19 08:09 +1000
Re: Shutting down a cross-platform multithreaded app Akira Li <4kir4.1i@gmail.com> - 2015-09-19 02:56 +0300
csiph-web