1

I want to make one pool to run tasks which should follow the queue and the order.

import multiprocessing
import time

def func(msg):
   for i in xrange(3):
      print msg
   time.sleep(2)

if __name__ == "__main__":
    pool = multiprocessing.Pool(processes=1)
    for i in xrange(10):
       msg = "hello %d" %(i)
       pool.apply_async(func, (msg, ))
    pool.close()

    time.sleep(50);
    print "Sub-process(es) done."   

It can print something. However there are not come up one by one. It will be done all immediately

Runpeng Chen
  • 105
  • 8
  • Possible duplicate of [RuntimeError on windows trying python multiprocessing](http://stackoverflow.com/questions/18204782/runtimeerror-on-windows-trying-python-multiprocessing) – Jacob Ritchie Oct 15 '15 at 04:05
  • 1
    Side-note: `time.sleep(50);` is a dumb way to do this. Just call `pool.join()` after `pool.close()` so you block until the process(es) are _actually_ done. – ShadowRanger Oct 15 '15 at 14:37
  • @ShadowRanger I know I am just testing. – Runpeng Chen Oct 15 '15 at 14:38

1 Answers1

0

Actually it runs at the different time. But it will show up at the same time.

Runpeng Chen
  • 105
  • 8