Skip to content

Instantly share code, notes, and snippets.

@xueruini
xueruini / context_local.py
Created March 8, 2017 06:29 — forked from virtuald/context_local.py
Implements a threadlocal-like mechanism for Tornado
'''
This is significantly derived from StackContext, Apache 2.0 license
'''
from tornado.stack_context import StackContextInconsistentError, _state
class ContextLocal(object):
'''
Implements a threadlocal-like mechanism that can be used to track data
across tornado asynchronous calls. This is very similar to (and based