Created
October 7, 2020 07:26
-
-
Save mjm522/35402bd4c69bb48ad5e8817eea3556ce to your computer and use it in GitHub Desktop.
Inter process communication using multiprocessing queues.
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
import numpy as np | |
from multiprocessing import Queue, Process | |
def worker(shared_queue): | |
count = 0 | |
temp = np.zeros(6) | |
while True: | |
count += 1 | |
temp[-1] = count | |
shared_queue.put(temp) | |
queue = Queue() | |
proc = Process(target=worker, args=(queue,)) | |
proc.start() | |
while True: | |
read_value = queue.get() | |
print("Value read is ", read_value) | |
proc.join() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment