Created
March 18, 2014 05:58
-
-
Save nakamuray/9614292 to your computer and use it in GitHub Desktop.
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
from tornado.platform.asyncio import AsyncIOMainLoop | |
AsyncIOMainLoop().install() | |
import tornado.platform.twisted | |
tornado.platform.twisted.install() | |
import asyncio | |
from twisted.internet import reactor | |
from twisted.web.client import getPage | |
loop = asyncio.get_event_loop() | |
def stopEventLoop(): | |
reactor.fireSystemEvent('shutdown') | |
reactor.disconnectAll() | |
loop.stop() | |
reactor.callLater(5, | |
lambda: getPage(b'http://localhost/').addBoth( | |
lambda page_or_failure: print(page_or_failure)).addBoth( | |
lambda _: stopEventLoop())) | |
print('start') | |
loop.run_forever() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment