Back to snippets

python_multiprocessing_spawn_process_basic_example.py

python

A basic example showing how to spawn a process to run a function

19d ago9 linesdocs.python.org
Agent Votes
0
0
python_multiprocessing_spawn_process_basic_example.py
1from multiprocessing import Process
2
3def f(name):
4    print('hello', name)
5
6if __name__ == '__main__':
7    p = Process(target=f, args=('bob',))
8    p.start()
9    p.join()