add some state-machine tracing

needs warner/automat/36-tracing branch
This commit is contained in:
Brian Warner 2017-02-25 13:13:30 -08:00
parent 97d1ff859b
commit c8be988801
2 changed files with 5 additions and 0 deletions

View File

@ -10,6 +10,8 @@ from . import _interfaces
class Mailbox(object):
_side = attrib(validator=instance_of(type(u"")))
m = MethodicalMachine()
@m.setTrace()
def setTrace(): pass
def __attrs_post_init__(self):
self._mood = None

View File

@ -40,6 +40,9 @@ class New(ServerBase, unittest.TestCase):
@inlineCallbacks
def test_basic(self):
w1 = wormhole.deferred_wormhole(APPID, self.relayurl, reactor)
def trace(old_state, input, new_state):
print("W1._M[%s].%s -> [%s]" % (old_state, input, new_state))
w1._boss._M.setTrace(trace)
w1.allocate_code(2)
code = yield w1.when_code()
print("code:", code)