David Bolen wrote: > > Michael Stroeder <michael at stroeder.com> writes: > > > I have two problems: > > > > 1. The server process does not detach from the console anymore (fork > > is used for that). This seems to work without the separate helper > > thread. > > > I'm not sure about (1) (perhaps depending on environment, the other > thread has its own reference to file handles that you normally close > before detaching, and you could try closing them before starting up > the thread?) It seems that I have some problems with file handles. Hmm, but the helper thread does not use file handles at all. Is there a way to determine which and/or how many file handles are used by a process/thread? > > 2. For testing purposes the server process can be started > > non-detached. In this case KeyboardInterrupt is catched by the main > > thread to shut down the process. This does not work with the helper > > thread but works without it. > > But for (2) if you have multiple threads around, then Python is going > to wait for those other threads to terminate when you try to exit > (it's basically the same as you doing a join() on each thread). So to > properly exit, you would want to write your helper threads to look for > some sort of sentinel or receive a message to tell them to exit when > you want the script to exit. I think that's what I have to do. Thanks for answering. > Alternatively, threads can be marked as a "daemon" via the threading > module setDaemon method, and those threads are permitted to still be > executing when the script exits. isDaemon() of the helper Thread object returns 0. Ciao, Michael.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4