I'm working with a program that works in parallel execution with dispy. I'm using dispy to create tasks and then distribute it to different CPUs to execution.
I have standar libraries and developed by me libraries (data and connection).
The code is like this:
import dispy
import sys
import data
import connection
def compute(num):
#some code that call data and connection methods, and generate a solution
return solution
def main():
cluster = dispy.JobCluster(compute)
jobs = []
for i in range(10)
job = cluster.submit(i)
job.id = i # optionally associate an ID to job (if needed later)
jobs.append(job)
for job in jobs:
job()
print "Result = " + str(job.result)
print "Exception = " + str(job.exception)
if __name__ == "__main__":
main()
`
The problem is that I need if a work with data and connection in the main def it works all fine, also if I call compute as a function instead of using the dispy library. But when I work like that and in the compute procedure call a data function it throws and exception that data is not defined and print exception None.
Any help? The documentation suggests of use setup but I can't figure out how it works.