As the title suggests, parallel processing using multiprocessing.Pool and multiprocessing.Queue does not work well.
What I want to achieve is to run multiple processes using multiprocessing.Pool and output the processing results of each process together in the parent process.
The executed program and the execution result are described below.
In the execution result, at the end
count 1 count 2
Was output, and the execution did not finish.
・ Windows command prompt
・ Python 3.6.3.
Executed source code
import multiprocessing import numpy as np def count (a, q): print ("count") print (a) q.put [a] if __name__ == "__main__": p = multiprocessing.Pool (2) # Up to 4 child processes at the same time m = multiprocessing.Manager () q = m.Queue () range_array = np.array ([1,2]) print ("start") for k in range_array: print ("function:" + str (k)) p.apply_async (count, args = (k, q)) print ('Waiting for all subprocesses done ...') print (q.get ()) p.close () p.join () print ('all process is done ...')
$>python test.py start function: 1 function: 2 Waiting for all subprocesses done ... count 1 count 2
Answer # 1
it might be.
- python - aggregation processing using pandas
- python - parallel processing with asyncio
- python 3x - processing to jump to the link destination using chrome driver in python
- python - tkinter parallel processing
- python - websocket processing using asyncio
- python - i want to separate by a specific word using the split function
- python - avoid processing when duplicated
- please explain the function using the python dictionary
- python:about processing such as timesleep and wxpython
- parameter estimation using python's weighted least squares method (wls)
- python - i want to draw parallel graphs that color-code numbers by sign, exponent, and mantissa
- python - about multiple processing and loop processing in discordpy
- processing using the len function when an integer value is obtained from python standard input
- about external libraries when using multiple versions of python
- about batch change of file name using python
- python - image recognition using cnn keras multiple inputs
- python iterative processing num is not defend
- python - speech processing typeerror:'int' object is not subscriptable
- processing python dat files