z25 / pyZOCP

Python ZOCP implementation (Z25 Orchestration Control Protocol)
GNU Lesser General Public License v3.0
33 stars 5 forks source link

fixed late subscription problems. #78

Closed sphaero closed 9 years ago

sphaero commented 9 years ago

When a node subscribes its own emitter to a sensor it needs to wait for the forwarded subscription from the receiver peer. In the meantime a signal can be emitted but not send to the receiver as the forwarded subscription is not yet received or parsed. However the emitter knew from the beginning that the receiver needed to receive the signal.

This PR fixes this. It already fills in the details during signal_(un)subscribe call.

Note: we are getting the same logic at multiple places. This is hard to maintain. However I propose to fix that when the whole capability tree is refactored!

Also added unsubscribe to the unittest

sphaero commented 9 years ago

build fail occasionally typically asynchronous events:

Traceback (most recent call last):
  File "tests/test_zocp.py", line 123, in test_self_emitter_subscribe
    self.assertNotIn("TestRecvFloat", self.node2.subscriptions.get(self.node1.uuid(), {}).get("TestEmitFloat", {}))
AssertionError: 'TestRecvFloat' unexpectedly found in ['TestRecvFloat']
sphaero commented 9 years ago

I also added a convenience method so you don't need to access the capability dictionary, just call get_value("name"), much nicer than self.capability["name"]["value"]. However IMHO this is just temporary. The capability tree can be much simpler.

Ready for merging!