File: client.py

package info (click to toggle)
pyro5 5.15-1
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 2,112 kB
  • sloc: python: 14,291; makefile: 163; sh: 66; javascript: 62
file content (11 lines) | stat: -rw-r--r-- 526 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
import random
from Pyro5.api import Proxy


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 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))