Skip to content

Instantly share code, notes, and snippets.

@saghul
Created May 26, 2011 21:15
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save saghul/994098 to your computer and use it in GitHub Desktop.
Decorator to run the decorated function in a ThreadPool and return a deferred
def run_in_db_thread(func):
"""Decorator to run DB queries in Twisted's thread pool"""
def wrapper(*args, **kw):
return deferToThreadPool(reactor, pool, func, *args, **kw)
return wrapper
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment