Created
September 17, 2018 19:03
-
-
Save ajx42/78d95cfcc6fcbf908deaa238dc15ab36 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## 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