Created
October 17, 2014 18:47
-
-
Save alexandre/96dddef82d9d0001d9f1 to your computer and use it in GitHub Desktop.
brincadeira com asyncio...seguindo o blogpost: http://junglecoders.blogspot.com.br/2014/06/python-asyncio-metodos-assincronos-em.html
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import asyncio | |
| def get_result(result, loop): | |
| print("Que bom que a função me mandou um '{}'".format(result)) | |
| loop.call_later(2, print_and_repeat, loop) | |
| def print_and_repeat(loop): | |
| result = 'Como vai?' | |
| print('Ok, vou mandar um {} para a aminha amiga função'.format(result)) | |
| loop.call_later(2, get_result, result, loop) | |
| loop = asyncio.get_event_loop() | |
| loop.call_soon(print_and_repeat, loop) | |
| loop.run_forever() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment