can someone help me share a list between multiple python processes. The problem is to get self.ID_List and self.mps_in_process working in the following code.
import time, random from multiprocessing import Process
In short, what the code does is that some data (here, random time in MP_Stuff) is processed according to the data identifier in self.ID_List. Self.mps_in_process is used to find out how many data identifiers are running (here nr-processes are hard-coded, but in reality they are dynamic).
The problem is to split mps_in_process and ID_List into several processes. The current code goes into a rather endless loop. What is wrong is actually well described in a multiprocessor library:
"if the code executed in the child process is trying to access the global variable, then the value that it sees (if any) may not coincide with the value in the parent process at the time of calling Process.start ()."
However, I cannot figure out how to work with mps_in_process and ID_List. I cannot use Queue since the elements deduced from mps_in_process are random. I cannot use Array because .pop (0) is not working. I can not use Manager (). List (), because then .reove () and len (ID_List) do not work. Using streaming instead of multiprocessing is not a solution because you need to use freeze_support ().
Therefore, any help on how to share the list between the processes is very welcome!
python list multiprocessing
bitman
source share