How can I know when a sub-process is effectively initialized?

G

Giampaolo Rodola'

Hi,
I'm working on a Python module called psutil [1] for reading process
information in a cross-platform way.
I'm having a problem with psutil test suite.
Almost all the test cases we implemented so far look like this:

def test_foo(self):
test_process = subprocess.Popen(sys.executable, stdout=DEVNULL,
stderr=DEVNULL)
time.sleep(0.1) # XXX: provisional, give some time the sub
process to initialize
p = psutil.Process(test_process.pid)
# start test here
...

As you can see we put a time.sleep(0.1) call after subprocess.Popen()
as a provisional workaround to let the sub process initialize
properly.
We're searching for some kind of way to know when the child process is
properly initialized so that we can actually start testing cases
without worries.
Does someone has an idea how could we do that?

[1] http://code.google.com/p/psutil/

Thanks a lot in advance,



--- Giampaolo
[1] http://code.google.com/p/pyftpdlib
 

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,755
Messages
2,569,536
Members
45,007
Latest member
obedient dusk

Latest Threads

Top