Skip to content

Instantly share code, notes, and snippets.

View beniwohli's full-sized avatar

Benjamin Wohlwend beniwohli

View GitHub Profile
@virtuald
virtuald / context_local.py
Last active June 18, 2020 08:10
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
@evansd
evansd / json.py
Last active August 29, 2015 14:01
from __future__ import absolute_import
import json
import re
from django import template
from django.utils.html import format_html_join
register = template.Library()