Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Re: PEP 3143: Standard daemon process library (was: Writing awell-behaved daemon)

Reply
Thread Tools

Re: PEP 3143: Standard daemon process library (was: Writing awell-behaved daemon)

 
 
Floris Bruynooghe
Guest
Posts: n/a
 
      03-20-2009
On Mar 20, 9:58*am, Ben Finney <(E-Mail Removed)> wrote:
> Ben Finney <(E-Mail Removed)> writes:
> > Writing a Python program to become a Unix daemon is relatively
> > well-documented: there's a recipe for detaching the process and
> > running in its own process group. However, there's much more to a
> > Unix daemon than simply detaching.

>
> […]
>
> > My searches for such functionality haven't borne much fruit though.
> > Apart from scattered recipes, none of which cover all the essentials
> > (let alone the optional features) of 'daemon', I can't find anything
> > that could be relied upon. This is surprising, since I'd expect this
> > in Python's standard library.

>
> I've submitted PEP 3143 <URL:http://www.python.org/dev/peps/pep-3143/>
> to meet this need, and have re-worked an existing library into a new
> ‘python-daemon’ <URL:http://pypi.python.org/pypi/python-daemon/>
> library, the reference implementation.
>
> Now I need wider testing and scrutiny of the implementation and
> specification.


Had a quick look at the PEP and it looks very nice IMHO.

One of the things that might be interesting is keeping file
descriptors from the logging module open by default. So that you can
setup your loggers before you daemonise --I do this so that I can
complain on stdout if that gives trouble-- and are still able to use
them once you've daemonised. I haven't looked at how feasable this is
yet so it might be difficult, but useful anyway.


Regards
Floris
 
Reply With Quote
 
 
 
 
Floris Bruynooghe
Guest
Posts: n/a
 
      03-24-2009
On Mar 21, 11:06*pm, Ben Finney <(E-Mail Removed)> wrote:
> Floris Bruynooghe <(E-Mail Removed)> writes:
> > Had a quick look at the PEP and it looks very nice IMHO.

>
> Thank you. I hope you can try the implementation and report feedback
> on that too.
>
> > One of the things that might be interesting is keeping file
> > descriptors from the logging module open by default.

>
> Hmm. I see that this would be a good idea. but it raises the question
> of how to manage the set of file handles that should not be closed on
> becoming a daemon.
>
> So far, the logic of closing the file descriptors is a little complex:
>
> * * * Close all open file descriptors. This excludes those listed in
> * * * the `files_preserve` attribute, and those that correspond to the
> * * * `stdin`, `stdout`, or `stderr` attributes.
>
> Extending that by saying “… and also any file descriptors for
> ``logging.FileHandler`` objects” starts to make the description too
> complex. I have a strong instinct that it the description is complex,
> the design might be bad.
>
> Can you suggest an alternative API that will ensure that all file
> descriptors get closed *except* those that should not be closed?


Not an answer yet, but I'll try to find time in the next few days to
play with this and tell you what I think. logging.FileHandler would
be too narrow in any case I think.


Regards
Floris
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: PEP 3143: Standard daemon process library (was: Writing awell-behaved daemon) Jean-Paul Calderone Python 0 03-20-2009 01:02 PM
Daemon Win32::Daemon; ph1975@gmail.com Perl Misc 0 09-07-2006 10:58 AM
PEP on path module for standard library Michael Hoffman Python 70 08-01-2005 12:03 PM
Proposed PEP: Treating Builtins as Constants in the Standard Library Raymond Hettinger Python 8 04-21-2004 11:31 AM
PEP 329: Treating Builtins as Constants in the Standard Library Raymond Hettinger Python 0 04-19-2004 12:54 PM



Advertisments