python - Why my subprocess STDOUT prints nothing under nohup -


i have code executed following way

$ python mycode.py param1 param2  

it produces output using subprocess inside mycode.py:

import subprocess paramlist = ['othercodes.py','infilel.txt']  p = subprocess.popen(paramlist,stdout=subprocess.pipe,stderr=subprocess.pipe) out, err = p.communicate()  # out empty under nohup print out 

i have no problem getting complete result using these commands:

 $ python mycode.py  > output.txt   $ python mycode.py   >> output.txt  

but when 1 of this, empty result in output.txt:

 $ nohup python mycode.py   > output.txt &  $ nohup python mycode.py   >> output.txt &  $ nohup python mycode.py   >> output.txt 2>&1   

what's correct way it?

update:

i fixed problem. pointed charlesduffy problem in othercodes.py. in particular these lines:

        # # if there's input ready, something, else         # # else. note timeout 0 select won't block @ all.          # if sys.stdin in select.select([sys.stdin], [], [], 0)[0]:         #     infile = sys.stdin.readline().strip()         #     args.append(infile) 

once commented out last 3 lines, mycode.py works fine.


Comments