Python Multithreading how to set 1 pool to run tasks as a queue -
i want make 1 pool run tasks should follow queue , order.
import multiprocessing import time def func(msg): in xrange(3): print msg time.sleep(2) if __name__ == "__main__": pool = multiprocessing.pool(processes=1) 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. there not come 1 one. done immediately
actually runs @ different time. show @ same time.
Comments
Post a Comment