Skip to content

Instantly share code, notes, and snippets.

@nakamuray
Created March 18, 2014 05:58
Show Gist options
  • Save nakamuray/9614292 to your computer and use it in GitHub Desktop.
Save nakamuray/9614292 to your computer and use it in GitHub Desktop.
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