Hello all,

First off, most righteous project - I was originally going to try to
use twisted.spread until I found out about rpyc - much simpler!

My question is simple - how, using rpyc.Service, do I expose a single
module on my server?

Right now, this is what I'm trying:

########################
import rpyc
import mymodule
class MyService(rpyc.Service):
    exposed_mymodule = mymodule

if __name__ == '__main__':
    from rpyc.utils.server import ThreadedServer
    t = ThreadedServer(MyService, port = 18861)
    t.start()
########################

Just running a test client interactively, I get this:

>>> c = rpyc.connect_by_service("My")
>>> c.root.mymodule
<module 'mymodule' from 'C:\....\mymodule.pyc'>
>>> c.root.mymodule.multiply(2,2)
======= Remote traceback =======
Traceback (most recent call last):
  File "C:\Python27\lib\site-packages\rpyc\core\protocol.py", line
227, in _dispatch_request
    res = self._HANDLERS[handler](self, *args)
  File "C:\Python27\lib\site-packages\rpyc\core\protocol.py", line
439, in _handle_getattr
    return self._access_attr(oid, name, (), "_rpyc_getattr",
"allow_getattr", getattr)
  File "C:\Python27\lib\site-packages\rpyc\core\protocol.py", line
402, in _access_attr
    raise AttributeError("cannot access %r" % (name,))
AttributeError: cannot access 'multiply'

======= Local exception ========
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Python27\lib\site-packages\rpyc\core\netref.py", line 93,
in __getattr__
    return syncreq(self, consts.HANDLE_GETATTR, name)
  File "C:\Python27\lib\site-packages\rpyc\core\netref.py", line 42,
in syncreq
    return conn().sync_request(handler, oid, *args)
  File "C:\Python27\lib\site-packages\rpyc\core\protocol.py", line
347, in sync_request
    raise obj
AttributeError: cannot access 'multiply'

So, how do I run a server that exposes an entire module, without
having to individually expose each method in the module?  I tried
looking at SlaveService, but somehow I think that's not the way I'm
meant to do this... so any help would be appreciated!

Reply via email to