Commit 3d54c114 authored by Benjamin Fischer's avatar Benjamin Fischer

workspace: added RPyC 4 compatibility

parent 8d94b601
......@@ -26,10 +26,14 @@ from vispa.models.workspace import Workspace
import cherrypy
import paramiko
import rpyc.core.stream
from rpyc.version import version as rpyc_version
import vispa.remote
import types
logger = logging.getLogger(__name__)
if rpyc_version[0] >= 4:
from rpyc.lib import Timeout
RPYC_COMPRESSION = False
_remote_files = []
......@@ -120,9 +124,6 @@ add_package_files(rpyc)
class LoggingService(rpyc.Service):
def __init__(self, conn):
rpyc.Service.__init__(self, conn)
def exposed_log(self, name, level, msg):
logging.getLogger(name).log(level, msg)
......@@ -284,6 +285,8 @@ class SSHConnectionImpl(object):
raise NotImplementedError
def poll(self, timeout):
if rpyc_version[0] >= 4:
timeout = Timeout(timeout).timeleft()
return self._in_buffer_event.wait(timeout)
def __init__(self, command, address,
......@@ -636,7 +639,8 @@ class Connection(object):
# send
logger.info("connect rpyc")
channel = rpyc.Channel(self._connection.stream(), False)
self.__rpyc = rpyc.Connection(LoggingService, channel, {"allow_public_attrs": True})
service = LoggingService() if rpyc_version[0] >= 4 else LoggingService
self.__rpyc = rpyc.Connection(service, channel, {"allow_public_attrs": True})
logger.info("connected rpyc")
self._connection.print_stderr()
......
......@@ -23,7 +23,7 @@ logging.basicConfig(
format="%(asctime)s - %(name)s - %(levelname)s - %(message)s")
logger = logging.getLogger("vispa.workspace-loader")
# use provided loglevel
# use provided loglevel
try:
loglevel = int(sys.stdin.readline())
except:
......@@ -194,9 +194,10 @@ def main_loop(fin, fout):
# connect the rpyc server to fifo
stream = rpyc.PipeStream(fin, fout)
channel = rpyc.Channel(stream, False)
service = Service() if rpyc.version.version[0] >= 4 else Service
vispa.remote.connection = rpyc.Connection(
Service, channel, {
'allow_public_attrs': True, 'allow_setattr': True})
service, channel, {
'allow_public_attrs': True, 'allow_setattr': True, 'timeout': 300})
vispa.remote.log = vispa.remote.connection.root.log
vispa.remote.send = vispa.remote.connection.root.send
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment