Exemple #1
0
def socket_coroutine():
    print("socket_coroutine start. ")
    client = socket.socket()
    client.connect(("", 1234))
    buffer = yield get_buffer(client)
    client.close()
    print("socket_coroutine stop. ")
    Return(buffer)
Exemple #2
0
def normal():
    a = yield 1
    print("Get a: %s" % a)
    b = yield 2
    print("Get b: %s" % b)
    c = yield 3
    print("Get c: %s" % c)
    Return(c)
Exemple #3
0
def bar():
    c = yield 333
    print("Got c: ", c)
    d = yield fun()
    print("Got d: ", d)
    e = yield fun()
    print("Got e", e)
    Return(c + d + e)
Exemple #4
0
def sum(a, b):
    print("Sum start. %s + %s" % (a, b))
    yield sleep(1)
    result = yield a + b
    print("Sum stop. %s + %s" % (a, b))
    Return(result)
Exemple #5
0
def aaddcthenmutilb(a, b, c):
    sum_result = yield sum(a, c)
    multi_result = yield multi(sum_result, b)
    Return(multi_result)
Exemple #6
0
def aaddbthenmutilc(a, b, c):
    sum_result = yield sum(a, b)
    multi_result = yield multi(sum_result, c)
    Return(multi_result)
Exemple #7
0
def multi(a, b):
    print("Multi start. %s x %s" % (a, b))
    yield sleep(2)
    result = yield a * b
    print("Multi stop. %s x %s" % (a, b))
    Return(result)
Exemple #8
0
def fun():
    a = yield 111
    print("Got a: ", a)
    b = yield 222
    print("Got b: ", b)
    Return(a + b)