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 stack_context as old, new_stack as new | |
| def exc(type, value, tb): | |
| return True | |
| def non_exc(type, value, tv): | |
| pass | 
  
    
      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
    
  
  
    
  | # For http://stackoverflow.com/questions/21248222/how-can-tornado-serve-a-single-static-file-at-an-arbitrary-location/21248691?noredirect=1#comment32053685_21248691 | |
| class MyFileHandler(StaticFileHandler): | |
| def initialize(self, file_mapping, **kwargs): | |
| self.file_mapping = file_mapping | |
| super(MyFileHandler, self).initialize(**kwargs) | |
| @classmethod | |
| def get_absolute_path(cls, root, path): | |
| return StaticFileHandler.get_absolute_path(root, self.file_mapping.get(path, path)) | 
  
    
      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
    
  
  
    
  | """Proof of concept tornado/tulip integration. | |
| Works with the current development branch of both projects as of | |
| Jan 20. Current status: The tornado test suite passes cleanly | |
| on a tulip-backed IOLoop. The tornado-backed event loop for tulip | |
| supports the core call_later and add_reader method families, but not | |
| the higher-level networking methods. | |
| To run the tornado test suite on tulip, make sure both projects | |
| and this file are on your python path and run: | 
  
    
      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 concurrent.futures import ThreadPoolExecutor | |
| from functools import partial, wraps | |
| import time | |
| import tornado.ioloop | |
| import tornado.web | |
| EXECUTOR = ThreadPoolExecutor(max_workers=4) | 
  
    
      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
    
  
  
    
  | #!/usr/bin/env python2.7 | |
| # -*- coding: utf-8 -*- | |
| # Copyright (c) 2014 Asumi Kamikaze Inc. | |
| # Licensed under the MIT License. | |
| # Author: Alejandro M. Bernardis | |
| # Email: alejandro (dot) bernardis (at) asumikamikaze (dot) com | |
| # Created: 06/Nov/2014 19:27 | |
| import boto | |
| from boto import jsonresponse | 
  
    
      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
    
  
  
    
  | import json | |
| from tornado import gen, ioloop | |
| from tornado.httpclient import AsyncHTTPClient, HTTPRequest | |
| from tornado.web import HTTPError | |
| AsyncHTTPClient.configure("tornado.curl_httpclient.CurlAsyncHTTPClient") | |
| class CoroutineModel(object): | |
  
    
      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
    
  
  
    
  | """ | |
| Testing with coroutines and yielding futures | |
| This programs final ouptput is 3 | |
| get_x, and get_y simulate an async task that returns later. | |
| """ | |
| import tornado.ioloop | |
| from tornado.concurrent import Future | |
| from tornado import gen | 
  
    
      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
    
  
  
    
  | # https://groups.google.com/forum/#!starred/python-tornado/VpHp3kXHP7s | |
| def start_httpserver(app_root, handler_map, opts): | |
| # create app and http server | |
| app = Application(handler_map, app_root, opts) | |
| http_server = tornado.httpserver.HTTPServer(app, xheaders=True) | |
| ioloop = tornado.ioloop.IOLoop.instance() | |
| def mem_check_scheduler(): | |
| easylog.debug("Call Check MEM") | 
  
    
      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, ioloop | |
| from tornado.httpclient import AsyncHTTPClient, HTTPRequest | |
| from tornado.web import HTTPError | |
| AsyncHTTPClient.configure("tornado.curl_httpclient.CurlAsyncHTTPClient") | |
| class CoroutineModel(object): | |
| @gen.coroutine | |
| def send_ok(self): | |
| try: | |
| request = HTTPRequest('https://google.com') | 
  
    
      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
    
  
  
    
  | #!/usr/bin/env python2.7 | |
| # -*- coding: utf-8 -*- | |
| # Copyright (c) 2014 Asumi Kamikaze Inc. | |
| # Licensed under the MIT License. | |
| # Author: Alejandro M. Bernardis | |
| # Email: alejandro (dot) bernardis (at) asumikamikaze (dot) com | |
| # Created: 20/Oct/2014 12:22 | |
| from base64 import encodestring, decodestring | |
| from Crypto import Random |