Commit 9c528d80 authored by Denis Bilenko's avatar Denis Bilenko

examples/processes.py: use the programs that are likely to be present

parent b3e3099e
......@@ -5,20 +5,20 @@ from gevent import subprocess
# run 2 jobs in parallel
p1 = subprocess.Popen(['uname'], stdout=subprocess.PIPE)
p2 = subprocess.Popen(['finger'], stdout=subprocess.PIPE)
p2 = subprocess.Popen(['ls'], stdout=subprocess.PIPE)
job1 = gevent.spawn(p1.stdout.read)
job2 = gevent.spawn(p2.stdout.read)
# wait for them to complete. stop waiting after 2 seconds
gevent.joinall([job1, job2], timeout=5)
gevent.joinall([job1, job2], timeout=2)
# print the results (if available)
if job1.ready():
print ('finger: %s bytes: %s' % (len(job1.value or ''), repr(job1.value)[:50]))
print ('uname: %s bytes: %s' % (len(job1.value or ''), repr(job1.value)[:50]))
else:
print ('finger: job is still running')
print ('uname: job is still running')
if job2.ready():
print ('netstat: %s bytes: %s' % (len(job2.value or ''), repr(job2.value)[:50]))
print ('ls: %s bytes: %s' % (len(job2.value or ''), repr(job2.value)[:50]))
else:
print ('netstat: job is still running')
print ('ls: job is still running')
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment