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

Using node as a delegate currently fails #36

Open
asmodehn opened this issue Apr 11, 2018 · 0 comments
Open

Using node as a delegate currently fails #36

asmodehn opened this issue Apr 11, 2018 · 0 comments
Labels

Comments

@asmodehn
Copy link
Member

Broken example :

class ServerNode(object):
    def __init__(self, name):
        self.node = pyzmp.Node(name)
        self.the_answer = 42
        self.node.provides(self.question)
    def question(self):
        return self.the_answer
    def __enter__(self):
        return self.node.__enter__()
    def __exit__(self ,type, value, traceback):
        return self.node.__exit__(type, value, traceback)
    
with ServerNode("srv") as srv:
    question = pyzmp.discover("question")
    question.call()
    
[srv] Proc started as [5973]
Shutdown initiated
Traceback (most recent call last):
  File "<input>", line 3, in <module>
  File "/home/alexv/Projects/pyzmp/pyzmp/service.py", line 142, in call
    reraise(pickle.loads(svcexc.exc_type), pickle.loads(svcexc.exc_value), tb.as_traceback())
  File "/home/alexv/Projects/pyzmp/pyzmp/node.py", line 221, in receive_reply
    resp = self._providers[req.service].func(*request_args, **request_kwargs)
  File "<input>", line 7, in question
AttributeError: 'Node' object has no attribute 'the_answer'

This needs to be thoroughly investigated...

A simple workaround for now is to inherit from Node which works fine and is usually tested.

@asmodehn asmodehn added the bug label Apr 11, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant