Skip to content

Instantly share code, notes, and snippets.

@mjm522
Created October 7, 2020 07:26
Show Gist options
  • Save mjm522/35402bd4c69bb48ad5e8817eea3556ce to your computer and use it in GitHub Desktop.
Save mjm522/35402bd4c69bb48ad5e8817eea3556ce to your computer and use it in GitHub Desktop.
Inter process communication using multiprocessing queues.
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