threads and concurrency process pools the following class allows you to create pool of processes to which various kind of data processing tasks can be submitted the functionality provided by pool is somewhat similar to that provided by list comprehensions and functional programming operations such as map-reduce pool([numprocess [,initializer [initargs]]]creates pool of worker processes numprocess is the number of processes to create if omittedthe value of cpu_count(is used initializer is callable object that will be executed in each worker process upon startup initargs is tuple of arguments to pass to initializer by defaultinitializer is none an instance of pool supports the following operationsp apply(func [args [kwargs]]executes func(*args**kwargsin one of the pool workers and returns the result it is important to emphasize this does not execute func in parallel in all pool workers if you want func to execute concurrently with different argumentsyou either have to call apply(from different threads or use apply_async( apply_async(func [args [kwargs [callback]]]executes func(*args**kwargsin one of the pool workers and returns the result asynchronously the result of this method is an instance of asyncresult which can be used to obtain the final result at later time callback is callable object that accepts single input argument when the result of func becomes availableit is immediately passed to callback callback should not perform any blocking operations or else it will block the reception of results in other asynchronous operations close(closes the process poolpreventing any further operations if any operations are still pendingthey will be completed before the worker processes terminate join(waits for all worker processes to exit this can only be called after close(or terminate( imap(funciterable [chunksize] version of map(that returns an iterator instead of list of results imap_unordered(funciterable [chunksize]]the same as imap(except that the results are returned in an arbitrary order based on when they are received from the worker processes map(funciterable [chunksize]applies the callable object func to all of the items in iterable and returns the result as list the operation is carried out in parallel by splitting iterable into chunks and farming out the work to the worker processes chunksize specifies the number of items in each chunk for large amounts of dataincreasing the chunksize will improve performance lib fl ff