File tree Expand file tree Collapse file tree 1 file changed +19
-9
lines changed Expand file tree Collapse file tree 1 file changed +19
-9
lines changed Original file line number Diff line number Diff line change @@ -972,20 +972,30 @@ As of Gevent 1.0, support has been added for cooperative waiting
972
972
on subprocess.
973
973
974
974
<pre >
975
- <code class =" python " >import gevent
975
+ <code class =" python " >
976
+ import gevent
976
977
from gevent.subprocess import Popen, PIPE
977
978
978
- # Uses a green pipe which is cooperative
979
- sub = Popen(['uname'], stdout=PIPE)
980
- read_output = gevent.spawn(sub.stdout.read)
981
-
982
- output = read_output.join()
983
- print(output.value)
984
- <code >
979
+ def cron():
980
+ while True:
981
+ print "cron"
982
+ gevent.sleep(0.2)
983
+
984
+ g = gevent.spawn(cron)
985
+ sub = Popen(['sleep 1; uname'], stdout=PIPE, shell=True)
986
+ out, err = sub.communicate()
987
+ g.kill()
988
+ print out.rstrip()
985
989
</pre >
986
990
987
991
<pre >
988
- <code class =" python " >Linux
992
+ <code class =" python " >
993
+ cron
994
+ cron
995
+ cron
996
+ cron
997
+ cron
998
+ Linux
989
999
<code >
990
1000
</pre >
991
1001
You can’t perform that action at this time.
0 commit comments