Created
July 25, 2014 16:50
-
-
Save lsbardel/7852beb5e18ceb5034a3 to your computer and use it in GitHub Desktop.
two loops in asyncio debug mode
This file contains 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 os | |
import logging | |
os.environ['PYTHONASYNCIODEBUG'] = 'debug' | |
os.environ['TROLLIUSDEBUG'] = 'debug' | |
import asyncio | |
import trollius | |
asyncio.set_event_loop_policy(trollius.get_event_loop_policy()) | |
def coro(): | |
loop2 = trollius.new_event_loop() | |
future = trollius.Future(loop=loop2) | |
loop2.call_later(1, future.set_result, 'Hi') | |
result = loop2.run_until_complete(future) | |
print(result) | |
yield | |
if __name__ == '__main__': | |
logging.basicConfig(level='DEBUG') | |
loop = trollius.get_event_loop() | |
loop.run_until_complete(coro()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment