Open pilhoon opened 3 years ago
import multiprocessing from os import getpid def worker(procnum): print('I am number %d in process %d' % (procnum, getpid())) return getpid() if __name__ == '__main__': pool = multiprocessing.Pool(processes = 3) print(pool.map(worker, range(5)))
https://stackoverflow.com/a/28799109/766330
Pool
Pool.starmap
just change map to starmap https://stackoverflow.com/a/5442981/766330
map
starmap
pool
use multiprocess.pool.ThreadPool (same usage with Pool) https://stackoverflow.com/a/58897266/766330
multiprocess.pool.ThreadPool
simple example
https://stackoverflow.com/a/28799109/766330
multiple arguments with
Pool
:Pool.starmap
just change
map
tostarmap
https://stackoverflow.com/a/5442981/766330call a local function from
pool
use
multiprocess.pool.ThreadPool
(same usage withPool
) https://stackoverflow.com/a/58897266/766330