I would like to pass numpy array to the multiprocessing queue. The program is working with small size arrays (20x20), however bigger size does not work. In general, I would like to pass 4D tensor with dimensions (100,1,16,12000). Running with python3.6 on Mac.
Code example:
import numpy as np
from multiprocessing import JoinableQueue, Process
class Writer(Process):
def __init__(self,que):
Process.__init__(self)
self.queue=que
def run(self):
for i in range(10):
data=np.random.randn(30,30)
self.queue.put(data)
print(i)
class Reader(Process):
def __init__(self,que):
Process.__init__(self)
self.queue=que
def run(self):
while not(self.queue.empty()):
result=self.queue.get()
print(result)
def main():
q = JoinableQueue()
w=Writer(q)
r=Reader(q)
w.start()
w.join()
print("DONE WRITING")
r.start()
r.join()
print("DONE READING")
if __name__ == "__main__":
main()
queue.put(data, block=False)?