Created
December 1, 2020 08:48
-
-
Save dbwodlf3/23428c527b00e531bc63e0788dc5d4a6 to your computer and use it in GitHub Desktop.
multi processing synchronization in python
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from multiprocessing import Process | |
| def bigJob(): | |
| # | |
| result = 0 | |
| # | |
| for i in range(12345678): | |
| result += i | |
| print(result) | |
| process_list = [] | |
| for i in range(12): | |
| p = Process(target=bigJob) | |
| p.start() | |
| process_list.append(p) | |
| for process in process_list: | |
| process.join() | |
| print('finished') | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment