Daemonization / Popen / pipe issue
java at leeclemens.net
Sat Mar 17 23:17:10 CET 2012
On 03/16/2012 11:37 PM, John O'Hagan wrote:
> On Fri, 16 Mar 2012 22:12:14 -0400
> Lee Clemens <java at leeclemens.net> wrote:
>> I have a multi-threaded application
>> I have provided a test-case here: https://gist.github.com/2054194
> I haven't looked at your test case yet, but a possible cause is the fact that
> the main application (or main thread) exits if it has finished executing and
> only daemon threads remain. This can abruptly terminate threads which may be
> busy, for example, communicating via a pipe. The best solution IMO is not to
> use daemon threads, but to give all threads a way to terminate cleanly before
> the main thread does, even if this means using a flag or the like.
I call .join() on each spawned thread, whether it is daemonized or not.
The code is available here:
Is it generally not recommended to daemonize Python applications using
this method? Do you have any references or data to support your opinion?
Do you have any references which specifically state - "Daemonizing
Python applications cause Python to work in unexpected ways."? As that
is what seems to be happening - data corrupting pipe redirection at an
More information about the Python-list