Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- async def uma_funcao():
- # algum código preparatório
- ...
- resultado = await outra_funcao(valores)
- # algumas linhas de código usando o resultado acima
- ...
- return valor
- import asyncio
- async def say(what, when):
- await asyncio.sleep(when)
- print(what)
- if when == 5:
- loop = asyncio.get_event_loop()
- loop.stop()
- loop = asyncio.new_event_loop()
- for i in range(5, -1, -1):
- loop.create_task(say(f'hello world {i}', i))
- print(f"co-rotina {i} criada")
- loop.run_forever()
- loop.close()
Add Comment
Please, Sign In to add comment