Skip to content Skip to sidebar Skip to footer

Profiling A Python Multiprocessing Pool

I'm trying to run cProfile.runctx() on each process in a multiprocessing pool, to get an idea of what the multiprocessing bottlenecks are in my source. Here is a simplified example

Solution 1:

Try this:

def square_wrapper(i):
    result = [None]
    cProfile.runctx("result[0] = square(i)", globals(), locals(), "file_%d" % i)
    return result[0]

Post a Comment for "Profiling A Python Multiprocessing Pool"