Skip to content

Commit

Permalink
fix compatibility with older python version
Browse files Browse the repository at this point in the history
  • Loading branch information
rlehfeld committed Apr 22, 2024
1 parent b922087 commit 208314d
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 24 deletions.
30 changes: 19 additions & 11 deletions RPyCRobotRemote/RPyCRobotRemoteClient.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,26 +61,34 @@ def __init__(self,
**rpyc_config):
self._keywords_cache = None

if timeout is not None:
timeout = convert_time(
timeout,
result_format='number'
)

if logger is None:
logger = logging.getLogger('RPyCRobotRemote.Client')

self._client = rpyc.connect(
peer,
port,
config=rpyc_config | {
config = {}
if rpyc_config:
config.update(rpyc_config)

config.update(
{
'allow_all_attrs': True,
'allow_getattr': True,
'allow_setattr': True,
'allow_delattr': True,
'allow_exposed_attrs': False,
'logger': logger,
} | ({} if timeout is None else {'sync_request_timeout': timeout}),
}
)

if timeout is not None:
config['sync_request_timeout'] = convert_time(
timeout,
result_format='number'
)

self._client = rpyc.connect(
peer,
port,
config=config,
ipv6=ipv6,
keepalive=True,
)
Expand Down
35 changes: 22 additions & 13 deletions RPyCRobotRemote/RPyCRobotRemoteServer.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,32 +111,41 @@ def _rpyc_setattr(self, name: str, value):
else pathlib.Path(port_file).absolute()
)

if timeout is not None:
timeout = convert_time(
timeout,
result_format='number'
)

if logger is None:
logger = logging.getLogger('RPyCRobotRemote.Server')

if server is None:
server = ThreadedServer

config = {}
if rpyc_config:
config.update(rpyc_config)

config.update(
{
'allow_all_attrs': True,
'allow_getattr': True,
'allow_setattr': True,
'allow_delattr': True,
'allow_exposed_attrs': False,
'logger': logger,
}
)

if timeout is not None:
config['sync_request_timeout'] = convert_time(
timeout,
result_format='number'
)

self._server = server(
Service(library),
hostname=host,
port=port,
ipv6=ipv6,
auto_register=False,
logger=logger,
protocol_config=rpyc_config | {
'allow_all_attrs': True,
'allow_getattr': True,
'allow_setattr': True,
'allow_delattr': True,
'allow_exposed_attrs': False,
} | ({} if timeout is None else {'sync_request_timeout': timeout})
protocol_config=config,
)

if serve:
Expand Down

0 comments on commit 208314d

Please sign in to comment.