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
|
from __future__ import print_function
import Pyro4
print("Showing the different instancing modes.")
print("The number printed, is the id of the instance that handled the call.")
print("\n-----PERCALL (different number every time) -----")
with Pyro4.Proxy("PYRONAME:instance.percall") as p:
print(p.msg("hello1"))
print(p.msg("hello2"))
print(p.msg("hello3"))
print("\n-----SESSION (same numbers within session) -----")
with Pyro4.Proxy("PYRONAME:instance.session") as p:
print(p.msg("hello1"))
print(p.msg("hello1"))
print(p.msg("hello1"))
print(" ..new proxy..")
with Pyro4.Proxy("PYRONAME:instance.session") as p:
print(p.msg("hello2"))
print(p.msg("hello2"))
print(p.msg("hello2"))
print("\n-----SINGLE (same number always) -----")
with Pyro4.Proxy("PYRONAME:instance.single") as p:
print(p.msg("hello1"))
print(p.msg("hello1"))
print(p.msg("hello1"))
with Pyro4.Proxy("PYRONAME:instance.single") as p:
print(p.msg("hello2"))
print(p.msg("hello2"))
print(p.msg("hello2"))
|