How does Python 3 multiprocessing Pool know when to pick another set of values? -
i have own package , want paralelize tasks doing. need open session, execute query , close session in single worker. having example multiprocessing documentation, script looks this:
from multiprocessing import pool owndb import odb def worker(y): session = odb('db_name', 'user', 'password') print(session) result = session.query("select name table") session.disconnect() return [y, result] if __name__ == '__main__': test_nums = [1,2,3,4,5,6] pool(processes=2) p: print(p.map(worker, test_nums)) this code, without openning , closing session works expected. when execute session code, results first set of pool workers (in case 2) , runs till kill it.
my assumption multiprocessing package not know when worker done - why be? how worker indicates finished?
Comments
Post a Comment