Re: forking and avoiding zombies!

Discussion in 'Python' started by andrea crotti, Dec 11, 2012.

  1. 2012/12/11 peter <>:
    > 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..
    andrea crotti, Dec 11, 2012
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. andrea crotti

    forking and avoiding zombies!

    andrea crotti, Dec 10, 2012, in forum: Python
    Replies:
    0
    Views:
    111
    andrea crotti
    Dec 10, 2012
  2. peter
    Replies:
    0
    Views:
    128
    peter
    Dec 10, 2012
  3. andrea crotti

    Re: forking and avoiding zombies!

    andrea crotti, Dec 11, 2012, in forum: Python
    Replies:
    0
    Views:
    142
    andrea crotti
    Dec 11, 2012
  4. peter
    Replies:
    0
    Views:
    114
    peter
    Dec 11, 2012
  5. andrea crotti

    Re: forking and avoiding zombies!

    andrea crotti, Dec 11, 2012, in forum: Python
    Replies:
    1
    Views:
    95
    Nobody
    Dec 12, 2012
Loading...

Share This Page