This is my working code:
class RPyCService(rpyc.SlaveService):
def __init__(self, conn):
super(RPyCService, self).__init__(conn)
...
from rpyc.utils.server import ThreadedServer
my_threaded_server = ThreadedServer(RPyCService, port=RPYC_SERVER_PORT)
my_threaded_server.start()
However, I would like to pass some arguments to the Services' __init__().
I tried
class RPyCService(rpyc.SlaveService):
def __init__(self, conn, asdf):
super(RPyCService, self).__init__(conn)
...
from rpyc.utils.server import ThreadedServer
asdf = "asdf"
my_threaded_server = ThreadedServer(RPyCService(asdf), port=RPYC_SERVER_PORT)
my_threaded_server.start()
but this gave me
Traceback (most recent call last): File "rpyc_server.py", line 145, in my_threaded_server = ThreadedServer(RPyCService(asdf), port=RPYC_SERVER_PORT) TypeError: init() takes exactly 3 arguments (2 given)
I am not sure if I have to add the conn argument somehow too. I was wondering where it comes from anyway ...
Passing an argument to an exposed service method is not an option in my case. I need to pass the argument when the services' __init__() is called.
How can I pass an argument to the __init__() of an rpyc.SlaveService object?