Commit f41ea421 authored by Robert Iannucci's avatar Robert Iannucci Committed by Robert Iannucci

Update processes.py example to work on windows.

The "Unable to run on windows" warning is actually about uname/ls, not
about gevent :)
parent 35286088
......@@ -5,24 +5,28 @@ from gevent import subprocess
import sys
if sys.platform.startswith("win"):
print("Unable to run on windows")
if sys.platform.startswith('win'):
UNAME = ['cmd.exe', '/C', 'ver']
LS = ['dir.exe']
else:
# run 2 jobs in parallel
p1 = subprocess.Popen(['uname'], stdout=subprocess.PIPE)
p2 = subprocess.Popen(['ls'], stdout=subprocess.PIPE)
UNAME = ['uname']
LS = ['ls']
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)
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')
gevent.wait([p1, p2], timeout=2)
p1.stdout.close()
p2.stdout.close()
# print the results (if available)
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