File: client.py

package info (click to toggle)
pyro4 4.82-2
  • links: PTS
  • area: main
  • in suites: bookworm
  • size: 2,528 kB
  • sloc: python: 17,736; makefile: 169; sh: 113; javascript: 62
file content (11 lines) | stat: -rw-r--r-- 524 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
import random
import Pyro4.errors


for _ in range(100):
    # 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(4567, 21000)
        result = w.factorize(n)
        print("%s factorized %d: %s" % (w._pyroConnection.objectId, n, result))