/usr/share/doc/pyro/examples/threadmobile/client.py is in pyro-examples 1:3.14-1.1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 | import threading
import time
import Pyro.core
import Pyro.util
import params.parameters
HOST="localhost"
URI = "PYROLOC://%s/test.threadmobile"
NUM_THREADS=10
if not Pyro.config.PYRO_MOBILE_CODE:
raise SystemExit("PYRO_MOBILE_CODE not enabled")
if Pyro.config.PYRO_XML_PICKLE=='gnosis' and Pyro.config.PYRO_GNOSIS_PARANOIA>=0:
raise SystemExit("Using gnosis xml pickle but PYRO_GNOSIS_PARANOIA needs to be -1")
startEvent = threading.Event()
def worker():
obj=Pyro.core.getProxyForURI(URI % HOST)
startEvent.wait()
name = threading.currentThread().getName()
print "worker", name
p = params.parameters.Parameter(name)
try:
result=obj.method(p)
print "result=",result,"calling method on it..."
result.method()
except Exception,x:
print "".join(Pyro.util.getPyroTraceback(x))
time.sleep(1)
print "exit"
HOST=raw_input("server host (empty for %s): " % HOST) or HOST
workers=[]
for i in range(NUM_THREADS):
w=threading.Thread(target=worker)
workers.append(w)
w.start()
time.sleep(0.1)
time.sleep(1)
print "starting!"
startEvent.set()
print "running"
for w in workers:
w.join()
print "done!"
|