Created
September 17, 2018 05:35
-
-
Save ajx42/4f87476d0cc5c46ecf0e164ca4a21444 to your computer and use it in GitHub Desktop.
PYRO4 Self Help
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
# START NAME SERVER AS: | |
$ pyro4-ns --host 172.22.134.7 --port 9090 | |
# SERVER CODE | |
import Pyro4 | |
@Pyro4.expose | |
class RemoteClass: | |
def __init__(self, x): | |
print("initialising remote object") | |
self.id = x | |
def call(self): | |
print("remote object called...") | |
daemon = Pyro4.Daemon(port=9999, host="172.22.134.7") | |
ns = Pyro4.locateNS() | |
uri = daemon.register(RemoteClass(7)) | |
ns.register("first_obj", uri) | |
print("Ready, object URI -> ", uri) | |
daemon.requestLoop() | |
# START THE SERVER | |
# CLIENT USING NAME SERVER | |
import Pyro4 | |
# get pyro proxy for the remote object | |
# without nameserver use the URI directly | |
my_remote_object = Pyro4.Proxy("PYRONAME:first_obj@172.22.134.7:9090") | |
my_remote_object.call() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment