/usr/share/doc/pyro/examples/sessions/basic_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 | #!/usr/bin/env python
import Pyro.core
import threading, time
NUMTHREADS=5
test = Pyro.core.getProxyForURI("PYRONAME://:test.threadstorage")
print "Will reuse the proxy in all threads."
print "Observe in the server console that the TLS counter is the same counter for all calls. "
def processing(index, proxy):
print 'Processing started',index
while threading.currentThread().running:
t1 = time.time()
print index, "CALLING...."
proxy.process("thread_"+str(index))
time.sleep(NUMTHREADS+1)
print "exiting thread",index
# start a set of threads which perform requests
threads=[]
for i in range(NUMTHREADS):
thread = threading.Thread(target=processing, args=(i, test))
threads.append(thread)
thread.running=True
time.sleep(0.5)
thread.start()
void=raw_input('\nPress enter to stop...\n\n')
print "Stopping threads."
for p in threads:
p.running=False
for p in threads:
p.join()
print 'stopped',p.getName()
print 'Graceful exit.'
|