Exemplo n.º 1
0
def cal(n):
    tot = 0
    for i in range(n):
        time1.sleep(0.1)
        tot += i

    return tot
def producer():
    c1 = consumer('sam')
    c2 = consumer('eva')

    c1.__next__()  #第一次迭代,函数停留在yield之后,下一次通过send触发迭代,导致product接收send过来的值
    c2.__next__()  #第一次迭代

    for product_id in range(2):
        print('生产者开始生产【包子%s】。。。' % product_id)
        time1.sleep(4)
        if product_id % 2 == 0:
            c1.send('包子%s' % product_id)
        else:
            c2.send('包子%s' % product_id)
def test1(name, age, gender):
    time1.sleep(3)
    print('test1函数运行完毕, 名字是[%s], 年龄是[%s], 性别[%s]' % (name, age, gender))
    return 'test1的返回值'
def test(name, age):
    time1.sleep(3)
    print('test函数运行完毕, 名字是[%s], 年龄是[%s]' % (name, age))
    return 'test的返回值'
def foo():
    time1.sleep(2)
    print('你好啊,嘉慧儿...')
def test():
    time1.sleep(3)
    print('test函数运行完毕')
Exemplo n.º 7
0
def test():
    time1.sleep(3)
    print('test函数运行完毕')
    return 'test的返回值'
Exemplo n.º 8
0
import os
import sys
from pprint import pprint as pp
import time1

pp(os.getcwd())
pp(sys.path)
pp(time1.__name__)
time1.sleep(2)