How to use the rpyc.classic.connect 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_splitbrain.py View on Github external
def setUp(self):
        enable_splitbrain()
        server_file = os.path.join(os.path.dirname(os.path.abspath(__file__)), "..", "bin", "rpyc_classic.py")
        self.proc = subprocess.Popen([sys.executable, server_file, "--mode=oneshot", "--host=localhost", "-p0"],
            stdin = subprocess.PIPE, stdout = subprocess.PIPE, stderr = subprocess.PIPE)
        line = self.proc.stdout.readline().strip()
        if not line:
            print (self.proc.stderr.read())
            self.fail("server failed to start")
        self.assertEqual(line, b("rpyc-oneshot"), "server failed to start")
        host, port = self.proc.stdout.readline().strip().split(b("\t"))
        self.conn = rpyc.classic.connect(host, int(port))
github tomerfiliba / rpyc / tests / test_gevent_server.py View on Github external
def test_parallelism(self):
        conns = [rpyc.classic.connect("localhost", port=18878)
                 for _ in range(50)]
        try:
            start = time.time()
            gevent.joinall([
                gevent.spawn(c.modules.time.sleep, 1)
                for c in conns
            ])
            stop = time.time()

            self.assertLessEqual(stop - start, 2)

        finally:
            for c in conns:
                c.close()
github mcieslik-mctp / papy / src / numap / NuMap.py View on Github external
It waits for tasks (function, data, arguments) at the input queue "inqueue"
    evaluates the result and passes it to the output queue "outqueue". It 
    optionally evaluates the function on a remote host.
    """
    put = outqueue.put
    get = inqueue.get
    if hasattr(inqueue, '_writer'):
        inqueue._writer.close()
        outqueue._reader.close()
    if host:
        host_port = host.split(':')
        try:
            host_port = [host_port[0], int(host_port[1])]
        except IndexError:
            pass
        conn = rpyc.classic.connect(*host_port)
        conn.execute(getsource(imports)) # provide @imports on server

    while True:
        try:
            #gc.disable()
            task = get()
            #gc.enable()
        except (EOFError, IOError):
            break

        if task is None:
            put(None)
            break

        if task[1] is None:
            put(task)
github onedata / onedata / profiling / setup_profile_ls.py View on Github external
#! /usr/bin/env python

import rpyc
import sys
import os

CLIENT_IP = sys.argv[1]
PATH = "/home/u1/onedata/s1"

conn = rpyc.classic.connect(CLIENT_IP)
for i in range(10):
    conn.modules.os.mkdir(os.path.join(PATH, str(i)))
conn.close()
github tomerfiliba / rpyc / issues / issue32.py View on Github external
import rpyc
import time

c = rpyc.classic.connect("localhost")
t = rpyc.BgServingThread(c)

start = time.time()
for i in range(100):
    c.execute("newObj = %d" % (i))
stop = time.time()
print "added %d simple objects one by one, %f seconds" % (100, stop - start)

t.stop()
github Morgan-Stanley / Xpedite / scripts / lib / xpedite / transport / remote.py View on Github external
re.compile(r'.*pid\<(?P[0-9]+)\>')])
      time.sleep(0.2)
      seconds += 0.2

    if not done:
      self.kill()
      with open(self.std.errPath, 'r') as err:
        errStr = err.read()
      raise Exception('Timed out trying to launch rpyc on {0} - stderr contents: {1}'.format(
                        self.host, errStr))

    self.port = int(extracts['port'])
    self.pid = int(extracts['pid'])

    pwd = os.environ['PWD']
    self.connection = rpyc.classic.connect(self.host, self.port, keepalive=self.keepalive)
    self.connection.modules.sys.stdout = sys.stdout
    if self.chdir:
      self.connection.modules.os.chdir(pwd)
      self.connection.modules.os.environ['PWD'] = pwd
    return self
github angr / angr-management / angrmanagement / app.py View on Github external
def spawn_child():
    port = random.randint(30000, 39999)
    cmd = ['python', '-c', '''from rpyc.core import SlaveService
#import logging
#logging.basicConfig(filename='child.log', level=logging.DEBUG)
from rpyc.utils.server import OneShotServer
OneShotServer(SlaveService, hostname='localhost', port={}).start()
'''.format(port)]
    subprocess.Popen(cmd)
    time.sleep(2.0)
    return rpyc.classic.connect('localhost', port)
github onedata / onedata / profiling / profile_read.py View on Github external
#! /usr/bin/env python

import rpyc
import sys
import subprocess
import os


CLIENT_IP = sys.argv[1]
CLIENT = sys.argv[2]
OP = sys.argv[3]
OZ = sys.argv[4]
PATH = "/home/u1/onedata/s1"
REMOUNT_SCRIPT = "./profiling/remount_client.sh"

conn = rpyc.classic.connect(CLIENT_IP)
file = os.path.join(PATH, "file")
subprocess.check_output([REMOUNT_SCRIPT, CLIENT, OP, OZ])
with conn.builtins.open(file, 'r') as f:
    f.read()
conn.close()
github onedata / onedata / profiling / setup_profile_rm.py View on Github external
#! /usr/bin/env python

import rpyc
import sys
import os

CLIENT_IP = sys.argv[1]
PATH = "/home/u1/onedata/s1"

conn = rpyc.classic.connect(CLIENT_IP)
dir_path=os.path.join(PATH, 'dir')
conn.modules.os.mkdir(dir_path)
for i in range(10):
    conn.modules.os.mkdir(os.path.join(dir_path, str(i)))
conn.close()