Skip to content
This repository has been archived by the owner on Jun 4, 2023. It is now read-only.

Commit

Permalink
PYROMETA example output fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
irmen committed Nov 17, 2016
1 parent f575821 commit af68c37
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion examples/distributed-computing3/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@
# this submits 100 factorization requests to a random available pyro server that can factorize.
# we do this in sequence but you can imagine that a whole pool of clients is submitting work in parallel.
with Pyro4.Proxy("PYROMETA:example3.worker.factorizer") as w:
n = number = random.randint(3211, 12000) * random.randint(3211, 11000)
n = number = random.randint(3211, 12000) * random.randint(4567, 21000)
result = w.factorize(n)
print("%s factorized %d: %s" % (w._pyroConnection.objectId, n, result))
8 changes: 5 additions & 3 deletions examples/distributed-computing3/worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,10 @@
class Worker(object):
@Pyro4.expose
def factorize(self, n):
print("factorize request recieved for", n)
return self._factorize(n)
print("factorize request received for", n)
result = self._factorize(n)
print(" -->", result)
return result

def _factorize(self, n):
"""simple algorithm to find the prime factorials of the given number n"""
Expand All @@ -28,7 +30,7 @@ def isPrime(n):
candidate = 2
while not primes and candidate in candidates:
if n % candidate == 0 and isPrime(candidate):
primes = primes + [candidate] + self.factorize(n // candidate)
primes = primes + [candidate] + self._factorize(n // candidate)
candidate += 1
return primes

Expand Down

0 comments on commit af68c37

Please sign in to comment.