How do I pass the __init __ () argument of the rpyc.SlaveService object?
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 Service __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 it gave me
Traceback (last call last): File "rpyc_server.py", line 145, in my_threaded_server = ThreadedServer (RPyCService (asdf), port = RPYC_SERVER_PORT) Error type: init () takes exactly 3 arguments (2)
I'm not sure if I need to add an argument as well conn
. I was wondering where this is coming from ...
Passing the argument to a public service method is not an option in my case. I need to pass an argument when services are called __init__()
.
How do I pass an __init__()
object argument rpyc.SlaveService
?
source to share
No one has answered this question yet
Check out similar questions: