Daemonization / Popen / pipe issue

L

Lee Clemens

Hello,

I am new to the list, have many years of Java experience but an fairly new to Python. I am hoping this is an issue caused by my misuse of Python in a multi-threaded way, but so far no one has identified such to me.

I have a multi-threaded application, each thread has an instance of a class which calls Popen. The command(s) being executed (shell=True) include pipes. The errors I have seen involve "broken pipe" and unexepected output (as demonstrated in the test case).

This issues only seem to occur when the application is "daemonized", using a double-fork and os.dup2, as shown here:
http://www.jejik.com/articles/2007/02/a_simple_unix_linux_daemon_in_python/

I have provided a test-case here: https://gist.github.com/2054194

Please test how flipping DAEMONIZE between True and False yield different results.

I have used this on Red Hat/CentOS/Fedora using Python 2.6.x (latest) and 2.7.1 and on Solaris with 2.6.4.

I know it's a bit long, but I have added comments to explain where the oddities appear and how it is called (fairly straight-forward multi-threaded). Please keep in mind this is a test-case based on a much larger application - I understand a lot of pieces included here are not necessary in this case.

Any assistance/advice would be greatly appreciated.

Thanks,
Lee
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,997
Messages
2,570,239
Members
46,827
Latest member
DMUK_Beginner

Latest Threads

Top