in the below code, in postTasksForNSegments() method, i am creating a process in a pool for each iteration. to confirm that there are several process started in every iteration i placed the print-statement
print(f".current_process:{multiprocessing.current_process}")
At run-time, i received the below posted output for the print-statement.
Given the memory address as stated below which is 0x0000017F7A4F1D80, does that mean i did not start several processes and it is only one process started?
please let me know why i am getting the same memory address every time? please tell me how to make sure that i did start several process in a pool?
if the code below indicates that it is only one process started, please let me know how to modify the code to start several processes
code:
@staticmethod
def initPool():
DebugGridCellsProcessingPerNRowsUsingPool.pool = Pool(cpu_count() -1)
@staticmethod
def closePool():
DebugGridCellsProcessingPerNRowsUsingPool.pool.close()
DebugGridCellsProcessingPerNRowsUsingPool.pool.join()
def postTasksForNSegments(self):
for i in range (0,self.numOfRows):
self.res = DebugGridCellsProcessingPerNRowsUsingPool.pool.map_async(self.run,[[
tasksCarierForRowsOfGridCellsClassifications,
tasksCarierForRowsOfNDVIsTIFFDetails,
tasksCarierForRowsOfPixelsValuesSatisfyThresholdInTIFFImageDatasetCnt,
tasksCarierForRowsOfPixelsValuesDoNotSatisfyThresholdInTIFFImageDatasetCnt,
tasksCarierForRowsOfpixelsValuesSatisfyThresholdInMixedNZCAndZCCnt,
....
....
....
tasksCarierForRowsOfPixelsValuesOfNoDataInNoDataCell,
]],
chunksize=self.numOfRows // cpu_count()
)
DebugGridCellsProcessingPerNRowsUsingPool.procs.append(self.res)
print(f".current_process:{multiprocessing.current_process}")
output of print-statement in the above code
numOfRows:30
(numOfSegments:3
.current_process:<function current_process at 0x0000017F7A4F1D80>
numOfRows:27
(numOfSegments:3
.current_process:<function current_process at 0x0000017F7A4F1D80>
numOfRows:24
(numOfSegments:3
.current_process:<function current_process at 0x0000017F7A4F1D80>
numOfRows:21
(numOfSegments:3
.current_process:<function current_process at 0x0000017F7A4F1D80>
numOfRows:18
(numOfSegments:3
.current_process:<function current_process at 0x0000017F7A4F1D80>
numOfRows:15
(numOfSegments:3
.current_process:<function current_process at 0x0000017F7A4F1D80>
numOfRows:12
(numOfSegments:3
.current_process:<function current_process at 0x0000017F7A4F1D80>
numOfRows:9
(numOfSegments:3
.current_process:<function current_process at 0x0000017F7A4F1D80>
numOfRows:6
(numOfSegments:3
.current_process:<function current_process at 0x0000017F7A4F1D80>
numOfRows:3
(numOfSegments:3
.current_process:<function current_process at 0x0000017F7A4F1D80>