This file contains 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 datetime import timedelta | |
from tornado import gen | |
from tornado.concurrent import run_on_executor | |
THREADPOOL_MAX_WORKERS = 10 | |
THREADPOOL_TIMEOUT_SECS = 30 | |
def onthread(function): |
This file contains 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
def shutdown(graceful=True): | |
"""Shut down the application. | |
If a graceful stop is requested, waits for all of the IO loop's | |
handlers to finish before shutting down the rest of the process. | |
We impose a 10 second timeout. | |
""" | |
ioloop = tornado.ioloop.IOLoop.instance() | |
def final_stop(): |
This file contains 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
class BaseHandler(RequestHandler): | |
# .... other stuff .... | |
def _handle_request_exception(self, e): | |
RequestHandler._handle_request_exception(self,e) | |
import pdb | |
pdb.post_mortem() | |
def bp(): |
This file contains 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
"""SQLAlchemy Metadata and Session object""" | |
from sqlalchemy import MetaData | |
from sqlalchemy.orm import scoped_session, sessionmaker | |
from sqlalchemy.orm.session import Session as SessionBase | |
from sqlalchemy.interfaces import ConnectionProxy | |
from datetime import datetime | |
import time | |
__all__ = ['Session', 'metadata', 'BaseModel'] |