def c2 (): n = Node () mtype_oucouc = n.reserve ('oucouc') mtype_coucou = n.reserve ('coucou') def a (msg): print 'coucou' n.register (mtype_coucou, a) m = Msg (mtype_oucouc) m.push ('B', 42) r = n.request (m) assert r.mtype == mtype_oucouc assert r.pop ('B') == (43,) n.wait_async (42) while not n.sync (): fds = select.select ((n, ), (), ())[0] for i in fds: i.read () n.wait ()
def c1 (): n = Node () mtype_coucou = n.reserve ('coucou') def a (msg): print 'oucouc' nb, = msg.pop ('B') nb += 1 m = Msg (msg.mtype) m.push ('B', nb) n.response (m) n.register ('oucouc', a) def b (): assert False eb = n.schedule (31, b) def c (): print 'hello' n.cancel (eb) n.schedule (28, c) m = Msg (mtype_coucou) n.send (m) n.wait ()