Commit 161460a4 authored by Jason Madden's avatar Jason Madden Committed by GitHub

Merge pull request #1378 from riannucci/fix_process_example

Update process.py example to work on windows.
parents 0086c621 f41ea421
...@@ -5,24 +5,28 @@ from gevent import subprocess ...@@ -5,24 +5,28 @@ from gevent import subprocess
import sys import sys
if sys.platform.startswith("win"): if sys.platform.startswith('win'):
print("Unable to run on windows") UNAME = ['cmd.exe', '/C', 'ver']
LS = ['dir.exe']
else: else:
# run 2 jobs in parallel UNAME = ['uname']
p1 = subprocess.Popen(['uname'], stdout=subprocess.PIPE) LS = ['ls']
p2 = subprocess.Popen(['ls'], stdout=subprocess.PIPE)
gevent.wait([p1, p2], timeout=2) # run 2 jobs in parallel
p1 = subprocess.Popen(UNAME, stdout=subprocess.PIPE)
p2 = subprocess.Popen(LS, stdout=subprocess.PIPE)
# print the results (if available) gevent.wait([p1, p2], timeout=2)
if p1.poll() is not None:
print('uname: %r' % p1.stdout.read())
else:
print('uname: job is still running')
if p2.poll() is not None:
print('ls: %r' % p2.stdout.read())
else:
print('ls: job is still running')
p1.stdout.close() # print the results (if available)
p2.stdout.close() if p1.poll() is not None:
print('uname: %r' % p1.stdout.read())
else:
print('uname: job is still running')
if p2.poll() is not None:
print('ls: %r' % p2.stdout.read())
else:
print('ls: job is still running')
p1.stdout.close()
p2.stdout.close()
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