5
from workitem import Workitem
7
WORKERNAME = "Worker_%d@%s" % (os.getpid(), socket.gethostname())
10
"""simple algorithm to find the prime factorials of the given number n"""
12
return not [x for x in xrange(2,int(sqrt(n))+1) if n%x == 0]
14
candidates = xrange(2,n+1)
16
while not primes and candidate in candidates:
17
if n%candidate == 0 and isPrime(candidate):
18
primes = primes + [candidate] + factorize(n/candidate)
23
print "factorizing",item.data,"-->",
25
item.result=factorize(int(item.data))
27
item.processedBy = WORKERNAME
30
dispatcher = Pyro.core.Proxy("PYRONAME:example.distributed.dispatcher")
31
print "This is worker",WORKERNAME
32
print "getting work from dispatcher."
35
item = dispatcher.getWork()
37
print "no work available yet."
40
dispatcher.putResult(item)
42
if __name__=="__main__":