public
Created

  • Download Gist
test.py
Python
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
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()

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.