We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent f5f385f commit 01396e6Copy full SHA for 01396e6
ParallelComputing/demo_poll_subprocess.py
@@ -0,0 +1,20 @@
1
+""" Demo creating a subprocess and doing something in the master process when
2
+the child is running. To know about the child's state we demo the poll method of
3
+the process.
4
+"""
5
+
6
+from subprocess import Popen
7
+import sys
8
+print "Starting..."
9
+# sleep for 10 seconds
10
+p = Popen(['sleep','10'])
11
+# continue on with processing
12
+print "Continuing",
13
+k=0
14
+while p.poll() is None:
15
+ k += 1
16
+ if (k % 100000) == 0:
17
+ print k//100000,
18
+ sys.stdout.flush()
19
+print
20
+print "Done", p.returncode
0 commit comments