How to use the rpyc.BgServingThread function in rpyc

To help you get started, we’ve selected a few rpyc examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github tomerfiliba / rpyc / tests / test_win32pipes.py View on Github external
def test_rpyc(self):
        assert self.client.root.get_service_name() == "VOID"
        t = rpyc.BgServingThread(self.client)
        assert self.server.root.get_service_name() == "VOID"
        t.stop()
github thrill / thrill / frontends / swig_python / RemoteThrill.py View on Github external
def __init__(self, rpyc_hosts, thrill_hosts):
        # connect to rpyc servers
        self._conn = [rpyc.connect(*hp) for hp in rpyc_hosts]
        # set up background serving threads
        self._bgthr = [rpyc.BgServingThread(conn) for conn in self._conn]
        # make async objects to create Thrill contexts
        anetrefs = [rpyc.async(conn.root.Create) for conn in self._conn]
        # issue async requests
        asyncs = [ref(rank, thrill_hosts) for rank, ref in enumerate(anetrefs)]
        for a in asyncs:
            a.wait()
        # get created Thrill contexts
        self._ctx = [a.value for a in asyncs]
github Luxoft / Twister / bin / start_client.py View on Github external
check = False

            try:
                proxy.root.hello('client', {'eps': ep_names})
                logPrint('Client Debug: Register EPs successful!')
            except Exception as e:
                logPrint('Exception: `{}`'.format(e))
                check = False

        if not check:
            if debug:
                logPrint('*ERROR* Cannot register! Cannot send hello on CE path `{}:{}`!'.format(ce_ip, ce_port))
            close_conn()
            return None

        BgServingThread(proxy)
        return proxy
github Luxoft / Twister / lib / TscCommonLib.py View on Github external
proxy = rpyc.connect(ce_ip, ce_port, config=config)
            proxy.root.hello('lib::{}'.format(cls.epName))
        except Exception:
            print('*ERROR* Cannot connect to CE path `{}`! Exiting!'.format(cls.proxy_path))
            raise Exception('Cannot connect to CE')

        # Authenticate on RPyc server
        try:
            proxy.root.login(cls.userName, 'EP')
        except Exception:
            print('*ERROR* Cannot authenticate on CE path `{}`! Exiting!'.format(cls.proxy_path))
            raise Exception('Cannot authenticate on CE')

        # Launch bg server
        try:
            BgServingThread(proxy)
            cls.__ce_proxy = proxy.root
            return cls.__ce_proxy
        except Exception:
            print('*ERROR* Cannot launch Bg serving thread! Exiting!')
            raise Exception('Cannot launch Bg thread')
github cgtoolbox / HCom / HComHoudini / HComHoudiniClient.py View on Github external
server_conn = rpyc.connect(HComHoudiniUtils.readIni()["SERVER"], int(HComHoudiniUtils.readIni()["PORT"]), service=HCom_ClientService, config={"allow_pickle":True})
    except Exception as e:
        print("ERROR: Can not connect to server: " + str(e))
        return False, False
    else:
        if ID in server_conn.root.getAllClients().keys():
            hou.ui.displayMessage("User ID already registered on the server")
            server_conn.close()
            return False
        
        hou.session.HCOMCLIENT = [server_conn, ID]
        
    global server_id
    server_id = ID
    
    bgsrv = rpyc.BgServingThread(server_conn)
    result = server_conn.root.registerClient(ID, clientType)
    
    if result:
        return ID
    else:
        return False
github Luxoft / Twister / client / executionprocess / ExecutionProcess.py View on Github external
ceProxy = None

    with proxyLock:
        # If the old connection is broken, connect to the RPyc server
        try:
            # Transform XML-RPC port into RPyc Port; RPyc port = XML-RPC port + 10 !
            p = rpyc.connect(ce_ip, int(ce_port) + 10, config=config)
            p.root.hello('ep::{}'.format(epName))
        except:
            print('*ERROR* Cannot connect to CE path `{}`! Exiting!'.format(cePath))
            return None

        # Authenticate on RPyc server
        try:
            check = p.root.login(userName, 'EP')
            bg = BgServingThread(p)
            ceProxy = p.root
            print('EP Debug: Connected and authenticated to CE at `{}`.\n'.format(cePath))
            return ceProxy
        except:
            print('*ERROR* Cannot authenticate on CE path `{}`! Exiting!'.format(cePath))
            return None

    return None
github tomerfiliba / rpyc / demos / filemon / client.py View on Github external
import rpyc
import time
import os


filename = "/tmp/floop.bloop"
if os.path.exists(filename):
    os.remove(filename)

f = open(filename, "w")
conn = rpyc.connect("localhost", 18871)
bgsrv = rpyc.BgServingThread(conn)  # create a bg thread to process incoming events


def on_file_changed(oldstat, newstat):
    print("file changed")
    print("    old stat: %s" % (oldstat,))
    print("    new stat: %s" % (newstat,))


mon = conn.root.FileMonitor(filename, on_file_changed)  # create a filemon

print("wait a little for the filemon to have a look at the original file")
time.sleep(2)

print("change file size")
f.write("shmoop")  # change size
f.flush()
github cgtoolbox / HCom / HComMaya / HComMayaClient.py View on Github external
return False, False
    else:
        if ID in server_conn.root.getAllClients().keys():
            ask = QtGui.QMessageBox()
            ask.setText("User ID already registered on the server")
            ask.setIcon(QtGui.QMessageBox.Critical)
            ask.exec_()
            server_conn.close()
            return False
        
        MayaGlobals.HCOMCLIENT = [server_conn, ID]
        
    global server_id
    server_id = ID
    
    bgsrv = rpyc.BgServingThread(server_conn)
    result = server_conn.root.registerClient(ID, clientType)
    
    if result:
        return ID
    else:
        return False