Skip to content

Instantly share code, notes, and snippets.

@mrjoes
Created November 16, 2012 11:16
Show Gist options
  • Save mrjoes/4086529 to your computer and use it in GitHub Desktop.
Save mrjoes/4086529 to your computer and use it in GitHub Desktop.
from tornado import gen, httpclient, ioloop, stack_context
io_loop = ioloop.IOLoop.instance()
client = httpclient.AsyncHTTPClient(io_loop=io_loop)
@gen.engine
def go_for_it():
c = 0
while True:
r = yield gen.Task(fetch)
c += 1
if c == 1000:
import pdb; pdb.set_trace()
if c % 100 == 0:
print '%s...' % c
@gen.engine
def fetch(callback):
#response = yield gen.Task(client.fetch, 'http://localhost:5000/')
yield gen.Task(io_loop.add_callback)
callback(None)
io_loop.add_callback(go_for_it)
io_loop.start()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment