- Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathlesson01_process.py
More file actions
Latest commit
17 lines (15 loc) · 500 Bytes
/
Copy pathlesson01_process.py
File metadata and controls
17 lines (15 loc) · 500 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
# SuperFastPython.com
# example of running a function in a new process
frommultiprocessingimportProcess
# custom function to be executed in a child process
deftask():
# report a message
print('This is another process', flush=True)
# protect the entry point
if__name__=='__main__':
# define a task to run in a new process
process=Process(target=task)
# start the task in a new process
process.start()
# wait for the child process to terminate
process.join()