0

i am working in sagemath doing some calculation and the process need to return a big array of numbers (the numbers in the array are RealField , for bigger precision) .I have work with thread librarie in c++ but in python i can't figure out how to implement it . i know that Queue() is limited in size `

import multiprocessing as mp
def foo(x):
   list=[]
   for i in range(0,1000000000):
      data=1
      #do something to data
      list.append(data)
   return list# retriev the data from process somehow 


if __name__ =="__main__":
   cores=4
   threads=[]
   for i in range(0,cores):
      threads.append(mp.Process(target=foo,args=(100)))
   for i in range(0,cores):
      threads[i].start()
   for i in range(0,cores):
      threads[i].join()

   #the system to retriev data 

`

i just need a way to return anything from process. An example would be even better

i tried Queue but after a size it's fails me . I have found this Python multiprocessing on windows with large arrays but i don't know how to modify for my problem

edit: i have write the code , the process is running as it shoud

  • the queue size is the size of your RAM, if it is failing you then you need more RAM, not another python container. – Ahmed AEK Nov 30 '22 at 07:34
  • ive found a resolve to this problem . i've created a `manager=mp.Manager() que=manager.list()` and ive pass it to the function and in the function i've appended ther and in the main process i could acces it – picantultunic Jun 30 '23 at 21:47

0 Answers0