Created
          November 16, 2012 11:16 
        
      - 
      
- 
        Save mrjoes/4086529 to your computer and use it in GitHub Desktop. 
  
    
      This file contains hidden or 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 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