3.2.8. effect.threads module

effect.threads.perform_parallel_with_pool(*args, **kwargs)

A performer for effect.ParallelEffects which uses a multiprocessing.pool.ThreadPool to perform the child effects in parallel.

Note that this can’t be used with a multiprocessing.Pool, since you can’t pass closures to its map method.

This function takes the pool as its first argument, so you’ll need to partially apply it when registering it in your dispatcher, like so:

my_pool = ThreadPool()
parallel_performer = functools.partial(
    perform_parallel_effects_with_pool, my_pool)
dispatcher = TypeDispatcher({ParallelEffects: parallel_performer, ...})

NOTE: ThreadPool was broken in Python 3.4.0, but fixed by 3.4.1. This performer should work for any version of Python supported by Effect other than 3.4.0.