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


Groups > comp.lang.python > #21850

Re: Daemonization / Popen / pipe issue

Path csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder.erje.net!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <cameron@cskk.homeip.net>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.001
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'received:edu.au': 0.07; 'send.': 0.07; 'subject:issue': 0.07; 'url:pypi': 0.08; 'python': 0.08; 'yet.': 0.15; 'accept,': 0.16; 'forking': 0.16; 'forks': 0.16; 'from:addr:cs': 0.16; 'from:addr:zip.com.au': 0.16; 'from:name:cameron simpson': 0.16; 'instance)': 0.16; 'liberal': 0.16; 'message-id:@cskk.homeip.net': 0.16; 'received:202.125.174': 0.16; 'received:202.125.174.133': 0.16; 'received:boardofstudies.nsw.edu.au': 0.16; 'received:cskk.homeip.net': 0.16; 'received:harvey.boardofstudies.nsw.edu.au': 0.16; 'received:homeip.net': 0.16; 'received:nsw.edu.au': 0.16; 'sense:': 0.16; 'cc:addr:python-list': 0.16; 'wrote:': 0.18; 'of.': 0.18; 'once,': 0.18; 'seems': 0.20; 'cheers,': 0.20; "haven't": 0.20; 'cc:no real name:2**0': 0.21; 'maybe': 0.21; 'header:In-Reply-To:1': 0.22; 'btw,': 0.23; 'mode': 0.25; 'obviously': 0.25; 'sat,': 0.25; 'cc:2**0': 0.26; 'module': 0.26; 'stuff': 0.26; 'code': 0.26; 'bit': 0.28; "i'm": 0.28; 'exit': 0.29; 'cc:addr:python.org': 0.29; 'generally': 0.30; 'practices.': 0.30; 'threads.': 0.30; '(the': 0.30; 'thread': 0.32; 'there': 0.33; 'header:User-Agent:1': 0.33; 'it.': 0.33; 'lee': 0.34; 'anything': 0.34; 'flag': 0.34; 'things': 0.35; 'external': 0.35; 'url:python': 0.35; 'received:au': 0.36; 'two': 0.36; 'but': 0.37; 'charset:us-ascii': 0.37; 'using': 0.37; 'url:org': 0.39; 'recommended': 0.39; 'entirely': 0.40; 'john': 0.61; 'more': 0.61; 'subject': 0.61; 'subject: / ': 0.63; 'internet': 0.64; 'received:202': 0.66; 'cameron': 0.77; 'clemens': 0.84; 'conservative': 0.84; 'jon': 0.84; 'lee,': 0.84; 'interest,': 0.91
Date Sun, 18 Mar 2012 15:15:48 +1100
From Cameron Simpson <cs@zip.com.au>
To John O'Hagan <research@johnohagan.com>
Subject Re: Daemonization / Popen / pipe issue
MIME-Version 1.0
Content-Type text/plain; charset=us-ascii
Content-Disposition inline
In-Reply-To <20120318123516.0c13a6345c333a040568b95a@johnohagan.com>
User-Agent Mutt/1.5.21 (2010-09-15)
References <20120318123516.0c13a6345c333a040568b95a@johnohagan.com>
Cc python-list@python.org
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.12
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.774.1332044158.3037.python-list@python.org> (permalink)
Lines 34
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1332044158 news.xs4all.nl 6878 [2001:888:2000:d::a6]:40788
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:21850

Show key headers only | 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