10
print "inside myThread().. calling mul...:",
12
print proxy.mul(222,10)
14
print ">>Exception in myThread:",x
15
print "done in myThread()."
18
Pyro.core.initClient()
20
test = Pyro.core.getAttrProxyForURI("PYRONAME://:test.simple")
22
print "Got a new proxy, first call is from a different thread (should work!)"
23
thread=threading.Thread(target=myThread, args=(test,) )
26
print "Now calling it from main thread (should fail)"
30
print "(expected) exception:",x
32
# create a copy of the proxy and use that instead. Should work.
33
print "Calling a copy of the proxy, that should work."
34
test2 = copy.copy(test)
35
print test2.mul(111,9)
37
# release the original proxy, and try again.
38
# this time it should work, because it is us that reconnect it...
39
print "releasing original proxy and calling again (should work now)"
45
# do again from a thread. This should fail now
46
print "Calling from a thread. Should now get exception about proxy sharing!"
47
thread=threading.Thread(target=myThread, args=(test,) )
51
# do again from a thread, but this time transfer ownership
52
# after that, when *we* attempt to call it it should fail instead... :)
53
print "\nCall again from a thread, but with thransfered ownership. No exception should occur this time."
54
print "Transfer ownership to thread..."
55
thread=threading.Thread(target=myThread, args=(test,) )
56
test._transferThread(thread) # usually, the thread itself calls this.
57
thread.start() # should work now
60
print "\n\ncalling ourselves again...(should get exception now):"
61
print test.mul(44,55) # should fail now