File tree Expand file tree Collapse file tree 1 file changed +20
-10
lines changed Expand file tree Collapse file tree 1 file changed +20
-10
lines changed Original file line number Diff line number Diff line change @@ -973,21 +973,31 @@ As of gevent 1.0, ``gevent.subprocess`` -- a patched version of Python's
973
973
subprocesses.
974
974
975
975
<pre >
976
- <code class =" python " >import gevent
976
+ <code class =" python " >
977
+ import gevent
977
978
from gevent.subprocess import Popen, PIPE
978
979
979
- # Uses a green pipe which is cooperative
980
- sub = Popen(['uname'], stdout=PIPE)
981
- read_output = gevent.spawn(sub.stdout.read)
982
-
983
- output = read_output.join()
984
- print(output.value)
985
- </code >
980
+ def cron():
981
+ while True:
982
+ print "cron"
983
+ gevent.sleep(0.2)
984
+
985
+ g = gevent.spawn(cron)
986
+ sub = Popen(['sleep 1; uname'], stdout=PIPE, shell=True)
987
+ out, err = sub.communicate()
988
+ g.kill()
989
+ print out.rstrip()
986
990
</pre >
987
991
988
992
<pre >
989
- <code class =" python " >Linux
990
- </code >
993
+ <code class =" python " >
994
+ cron
995
+ cron
996
+ cron
997
+ cron
998
+ cron
999
+ Linux
1000
+ <code >
991
1001
</pre >
992
1002
993
1003
Many people also want to use `` gevent `` and `` multiprocessing `` together. One of
You can’t perform that action at this time.
0 commit comments