Why we should use registry class?

39 views
Skip to first unread message

Mahmoodreza Aarabi

unread,
Feb 15, 2014, 11:39:26 AM2/15/14
to rp...@googlegroups.com
hi guys
i want to know that why we should use registry classes?
and please tell me how should using it for service mode?!

thanks

Mahmoodreza Aarabi

unread,
Feb 16, 2014, 12:29:38 PM2/16/14
to rp...@googlegroups.com
you know..
i have three file that i want to creat my own registry server with one server and one client
please tell me that if i do right or wrong way.
----------------------------------------------------
my_registry.py:
    from rpyc.utils.registry import TCPRegistryServer

    def main():
        server = TCPRegistryServer("localhost", port=20202)
        print "Registry server is ready..."
        server.start()

    if __name__ == "__main__":
        main()
----------------------------------------------------
simpleServer.py:

import rpyc
from rpyc.utils.server import ThreadedServer
from rpyc.utils.registry import TCPRegistryClient

class ServerService(rpyc.Service):   

    def on_connect(self):
        print "connected"

    def on_disconnect(self):
        print "disconnected"


    def exposed_test1(self):
        print "test1"

if __name__ == "__main__":
    tcp_registrar = TCPRegistryClient("localhost", port=20202)
    server = ThreadedServer(ServerService, port=2014, registrar=tcp_registrar)
    print "Server is ready..."
    server.start()
----------------------------------------------------
simpleClient.py:

import rpyc
from rpyc.utils.registry import TCPRegistryClient

class ClientService(rpyc.Service):   
    def exposed_test1(self):
        print "test1: "


reg = TCPRegistryClient("localhost", port=20202)
conn = rpyc.connect("localhost", port=2014, service=ClientService)

rpyc.discover("Server", registrar=reg)

conn.close()
----------------------------------------------------
please guide me
Reply all
Reply to author
Forward
0 new messages