Writing to a file with multiprocessing

前端 未结 3 892
孤街浪徒
孤街浪徒 2020-12-09 04:34

I\'m having the following problem in python.

I need to do some calculations in parallel whose results I need to be written sequentially in a file. So I created a fu

3条回答
  •  无人及你
    2020-12-09 05:25

    There is a mistake in the write worker code, if the block is false, the worker will never get any data. Should be as follows:

    par, res = queue.get(block = True)
    

    You can check it by adding line

     print "QSize",queueOut.qsize()
    

    after the queueOut.put((par,res))

    With block=False you would be getting ever increasing length of the queue until it fills up, unlike with block=True where you get always "1".

提交回复
热议问题