def player(name, table): while True: ball = yield take(table) ball.hits += 1 print name, ball.hits yield sleep(0.1) yield put(table, ball)
def main(): table = Channel() go(player, "ping", table) go(player, "pong", table) yield put(table, Ball()) yield sleep(1)
def main(): chan = go_chan(lazy_echo, 1) print (yield take(chan)) chan = go_chan(lazy_echo, 2) yield sleep(1) print (yield take(chan)) yield stop("Done")
def produce(chan, value): yield sleep(0.1) yield put(chan, value)
def t(): yield sleep(seconds) chan.close()
def closing(): yield sleep(0.005) ch.close()
def taking(): yield sleep(0.005) yield take(ch)
def putting(): yield sleep(0.005) yield put(ch, 42)
def _do(): i = 0 while True: yield put(c, "%s %d" % (message, i)) yield sleep(random.random()) i += 1
def lazy_echo(x): yield sleep(0.1) print "I'm done" yield stop(x)