Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cannot access 'items' on server #347

Closed
ralfkundel opened this issue Sep 11, 2019 · 1 comment
Closed

cannot access 'items' on server #347

ralfkundel opened this issue Sep 11, 2019 · 1 comment
Assignees
Labels
Done The issue discussion is exhausted and is closed w/ comment

Comments

@ralfkundel
Copy link

ralfkundel commented Sep 11, 2019

Hi,
thanks to #272 i was able to access a dict on the client side. however, I'm unable to transfer a dict from client to server and access items().

Server:

class TimeService(Service):
    def exposed_get_a_dict(self, a):
        print(a)
        for k,v in a.items():
            print(k)
        return "asdf" 
s = ThreadedServer(TimeService, port=18871, protocol_config={'allow_public_attrs': True, 'sync_request_timeout': 10})
s.start()

Client:

conn = rpyc.connect('localhost', 18871)
foo = conn.root.get_a_dict({'yeah':42})

causes: AttributeError: cannot access 'items'

Is there another protocol_config which is required for that?

Used version: ubuntu 19.04, python3, current RPyC version

regards,
Ralf

@comrumino comrumino self-assigned this Sep 14, 2019
@comrumino comrumino added the To Start Description reviewed and a maintainer needs "to start" triage label Sep 14, 2019
@comrumino
Copy link
Collaborator

comrumino commented Sep 23, 2019

RPyC supports bidirectional communication; so, client.py behaves as a server and a client in your use case. Being so, it must be configured to allow_public_attrs: True when you would like server.py to access public attributes of remote objects belonging to client.py.
server.py

import rpyc


class TimeService(rpyc.Service):
    def exposed_get_a_dict(self, a):
        print(a)
        for k, v in a.items():
            print(k)
        return "asdf"


s = rpyc.utils.server.ThreadedServer(TimeService, port=18871, protocol_config={
                                     'allow_public_attrs': True, 'sync_request_timeout': 10})
s.start()

client.py

import rpyc
conn = rpyc.connect('localhost', 18871, config={'allow_public_attrs': True, 'sync_request_timeout': 10})
foo = conn.root.get_a_dict({'yeah': 42})

Hope that helps! If you run into anything else that is related, reopen the issue and I can help out.

@comrumino comrumino added Done The issue discussion is exhausted and is closed w/ comment and removed To Start Description reviewed and a maintainer needs "to start" triage labels Sep 23, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Done The issue discussion is exhausted and is closed w/ comment
Projects
None yet
Development

No branches or pull requests

2 participants