import asyncio @asyncio.coroutine def fa(num): f=1 for i in range(2,num+1): print("Asyncio.Task:Computer factories({})".format(i)) yield from asyncio.sleep(1) f=i print("Asyncio.Task - factorial({}) ={}".format(num,f)) @asyncio.coroutine def fi(num): a,b=0,1 for i in range(2, num + 1): print("Asyncio.Task:Computer fibonacci({})".format(i)) yield from asyncio.sleep(1) a,b=b,a+b print("Asyncio.Task - fibonacci({}) ={}".format(num, a)) @asyncio.coroutine def bi(n,k): result=1 for i in range(1,k+1): result=result(n-i+1)/i print("Asyncio.Task:Computer binomialcoeff({})".format(i)) yield from asyncio.sleep(1) print("Asyncio.Task - binomialcoeff({},{}) ={}".format(n,k,result)) if name=="main": tasks=[asyncio.Task(fa(10)),asyncio.Task(fi(10)),asyncio.Task(bi(20,10))] loop=asyncio.get_event_loop() loop.run_until_complete(asyncio.wait(tasks)) loop.close()