Skip to content

Instantly share code, notes, and snippets.

@ajx42
Created September 17, 2018 19:03
Show Gist options
  • Save ajx42/78d95cfcc6fcbf908deaa238dc15ab36 to your computer and use it in GitHub Desktop.
Save ajx42/78d95cfcc6fcbf908deaa238dc15ab36 to your computer and use it in GitHub Desktop.
## This keeps adding 90 to the idd value in Server
## Never name the method (for setter and value) same as the attr name, will result in recursive calls (seg fault)
# SERVER
import Pyro4
@Pyro4.expose
class RemoteClass:
def __init__(self, x):
print("initialising remote object")
self.idd = x
@Pyro4.expose
@property
def hu(self):
return self.idd
@Pyro4.expose
@hu.setter
def hu(self, val):
self.idd = val
def call(self):
print("remote object called...")
def px(self):
print(self.idd)
daemon = Pyro4.Daemon(port=8798)
ns = Pyro4.locateNS()
uri = daemon.register(RemoteClass(7))
ns.register("first_obj", uri)
print("Ready, object URI -> ", uri)
daemon.requestLoop()
# CLIENT
import Pyro4
# uri = input().strip()
# get pyro proxy for the remote object
my_remote_object = Pyro4.Proxy("PYRONAME:first_obj")
my_remote_object.call()
my_remote_object.hu += 90
my_remote_object.px()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment