import thread from greensock import * from threadchannel import ThreadChannel, startup, shutdown def test_threadchannel(): startup() ev1 = ThreadChannel() ev2 = ThreadChannel() def g1(): lst.append(0) x = ev2.receive() assert x == 'hello' lst.append(2) ev1.send('world') lst.append(5) def g2(): lst.append(1) ev2.send('hello') lst.append(3) y = ev1.receive() assert y == 'world' lst.append(4) shutdown() lst = [] autogreenlet(g1) thread.start_new_thread(g2, ()) mainloop() assert len(lst) == 6 assert sorted(lst[0:2]) == [0, 1] assert sorted(lst[2:4]) == [2, 3] assert sorted(lst[4:6]) == [4, 5]