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


Groups > comp.lang.python > #34618

Re: forking and avoiding zombies!

References (1 earlier) <50C6153F.8050205@gmail.com> <CAF_E5JbPa9gb_a7o1ZgwaNfhu_ycz+CdnMCvhDe2VC8Dy5WAgA@mail.gmail.com> <50C7282B.8000708@gmail.com> <CAF_E5JZfqEsxxfCoE_TzOAxjPhwgzFe+M_MmwBUwHURdVGZLKQ@mail.gmail.com> <50C7365F.20908@gmail.com>
Date 2012-12-11 13:57 +0000
Subject Re: forking and avoiding zombies!
From andrea crotti <andrea.crotti.0@gmail.com>
Newsgroups comp.lang.python
Message-ID <mailman.726.1355234225.29569.python-list@python.org> (permalink)

Show all headers | View raw


2012/12/11 peter <pjmakey2@gmail.com>:
> On 12/11/2012 10:25 AM, andrea crotti wrote:
>>
>> Ah sure that makes sense!
>>
>> But actually why do I need to move away from the current directory of
>> the parent process?
>> In my case it's actually useful to be in the same directory, so maybe
>> I can skip that part,
>> or otherwise I need another chdir after..
>
> You don't need to move away from the current directory. You cant use os to
> get the current work directory
>
> stderrfile = '%s/error.log' % os.getcwd()
> stdoutfile = '%s/out.log' % os.getcwd()
>
> then call the daemon function like this.
>
> daemonize(stdout=stdoutfile, stderr=stderrfile)


But the nice thing now is that all the forked processes log also on
stdout/stderr, so if I launch the parent in the shell I get

DEBUG -> csim_flow.worker[18447]: Moving the log file
/user/sim/tests/batch_pdump_records/running/2012_12_11_13_4_10.log to
/user/sim/tests/batch_pdump_records/processed/2012_12_11_13_4_10.log

DEBUG -> csim_flow.area_manager[19410]: No new logs found in
/user/sim/tests/batch_pdump_records

where in [] I have the PID of the process.
In this suggested way I should use some other files as standard output
and error, but for that I already have the logging module that logs
in the right place..

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


Thread

Re: forking and avoiding zombies! andrea crotti <andrea.crotti.0@gmail.com> - 2012-12-11 13:57 +0000

csiph-web