Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #21850

Re: Daemonization / Popen / pipe issue

Date 2012-03-18 15:15 +1100
From Cameron Simpson <cs@zip.com.au>
Subject Re: Daemonization / Popen / pipe issue
References <20120318123516.0c13a6345c333a040568b95a@johnohagan.com>
Newsgroups comp.lang.python
Message-ID <mailman.774.1332044158.3037.python-list@python.org> (permalink)

Show all headers | View raw


On 18Mar2012 12:35, John O'Hagan <research@johnohagan.com> wrote:
| On Sat, 17 Mar 2012 18:17:10 -0400
| Lee Clemens <java@leeclemens.net> wrote:
| > Is it generally not recommended to daemonize Python applications using
| > this method? 
| 
| I'm no guru, but not that I know of. I haven't seen the os.fork method you use
| before; out of interest, why not use Thread.setDaemon? 

They are two entirely different practices. Thread.setDaemon is a flag
for a particular thread telling the python system to not bother waiting
for it at exit time. The daemonize stuff Lee is using is "daemon" in the
UNIX sense: forking the main process (the whole python instance) into an
unassociated process not subject to job control etc.

I glanced at Lee's code and have seen found anything obviously wrong yet.
Maybe if I get a bit more time later.

It seems that in daemon mode the code forks first, exactly once, before
firing off any subprocesses or threads. Is this correct? If the
daemonising happened per thread that would be very bad.

BTW, Lee, there is an external module for daemonising things in the UNIX
sense:
  http://pypi.python.org/pypi/python-daemon
I recommend you use it.

Cheers,
-- 
Cameron Simpson <cs@zip.com.au> DoD#743
http://www.cskk.ezoshosting.com/cs/

The First Law of Internet Communications:
Be liberal in what you accept, and conservative in what you send. - Jon Postel

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re: Daemonization / Popen / pipe issue Cameron Simpson <cs@zip.com.au> - 2012-03-18 15:15 +1100

csiph-web