- Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathlesson03_exitcode.py
More file actions
Latest commit
24 lines (22 loc) · 626 Bytes
/
Copy pathlesson03_exitcode.py
File metadata and controls
24 lines (22 loc) · 626 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# SuperFastPython.com
# example of checking the exit status of a child process
fromtimeimportsleep
frommultiprocessingimportProcess
# custom function to be executed in a child process
deftask():
# block for a moment
sleep(1)
# protect the entry point
if__name__=='__main__':
# create the process
process=Process(target=task)
# report the exit status
print(process.exitcode)
# start the process
process.start()
# report the exit status
print(process.exitcode)
# wait for the process to finish
process.join()
# report the exit status
print(process.exitcode)