subprocess seems to "detach" / ignore wait()

Mathieu Prevot mathieu.prevot at ens.fr
Thu Aug 21 05:17:58 EDT 2008


2008/8/21 Gabriel Genellina <gagsl-py2 at yahoo.com.ar>:
> En Thu, 21 Aug 2008 02:46:06 -0300, Mathieu Prevot <mathieu.prevot at ens.fr> escribió:
>
>>> So what is the right thing to do so my script
>>> returns 1 or 0 depending on its state and success ?
>
> I use something like this:
>
> def main(argv):
>  try:
>    try:
>      do_things()
>      return 0
>    finally:
>      do_cleanup()
>  except:
>    log_exception()
>    return 1
>
> if __name__=='__main__':
>  import sys
>  sys.exit(main(sys.argv))
>
>> PS: BTW how can I detach my process ie have an equivalent to
>> `myscript.py&` from the python script ?
>
> There are a few recipes in the Python CookBook at http://code.activestate.com/recipes/langs/python/

The return from main()... it was my thought too.
Thank you Gabriel :)

Mathieu



More information about the Python-list mailing list