Esempio n. 1
0
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 main():
    c = boring("Joe")
    while True:
        value, chan = yield alts([c, timeout(0.8)])
        if chan is c:
            print value
        else:
            print "You're too slow."
            yield stop()
def main():
    c = boring("Joe")
    t = timeout(5)
    while True:
        value, chan = yield alts([c, t])
        if chan is c:
            print value
        else:
            print "You talk too much."
            yield stop()
 def ident(x):
     yield stop(x)
Esempio n. 5
0
def lazy_echo(x):
    yield sleep(0.1)
    print "I'm done"
    yield stop(x)