Skip to content

Using node as a delegate currently fails #36

@asmodehn

Description

@asmodehn

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions