Search code examples
pythonparallel-python

How to make stdout works with Parallel Python?


I'm wondering if it is possible to make stdout works with Parallel Python? It's really hard to debug without seeing any print-out.

For example, given the following code snippets:

import pp

def printit(s):
    print s

job_server = pp.Server()
for i in xrange(100):
    job_server.submit(printit, (i,))
job_server.wait()

There is not any print out. Any ideas?


Solution

  • Look into using the logging module. Set up your "parent" program to listen on a network port, and have your "jobs" send debug info (using logging) to that port. An example of how to set this up is given here: http://docs.python.org/2/howto/logging-cookbook.html#sending-and-receiving-logging-events-across-a-network