-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
97819a7
commit 3d26782
Showing
2 changed files
with
33 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import random | ||
import multiprocessing | ||
|
||
|
||
def list_append(count, id, out_list): | ||
# appends the count of number of processes which takes place at a time | ||
for i in range(count): | ||
out_list.append(random.random()) | ||
|
||
if __name__ == "__main__": | ||
size = 999 | ||
procs = 2 | ||
# Create a list of jobs and then iterate through | ||
# the number of processes appending each process to | ||
# the job list | ||
jobs = [] | ||
|
||
for i in range(0, procs): | ||
out_list = list() # list of processes | ||
process1 = multiprocessing.Process( | ||
target=list_append, args=(size, i, out_list)) | ||
|
||
# appends the list of processes | ||
jobs.append(process1) | ||
|
||
# Calculate the random number of processes | ||
for j in jobs: | ||
j.start() # initiate the process | ||
|
||
# After the processes have finished execution | ||
for j in jobs: | ||
j.join() | ||
print("List processing complete.") |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.