Below is some (commented) example code.
# Use multiprocessing backend.
backend = MPBackend()
# Start the thread that listens for I/O from the processes.
backend.iohandler.start()
# Do some calculations.
a = backend.spawn(reduce, operator.mul, xrange(1, 50000))
b = backend.spawn(reduce, operator.mul, xrange(1, 50000))
# When you need the results, sync them.
a, b = sync(a, b)
# When done, shut down the I/O thread so the application can exit.
backend.iohandler.stop()
No comments:
Post a Comment