Skip to content

Instantly share code, notes, and snippets.

View xkal36's full-sized avatar
🏠
Working from home

Andrew Winterbotham xkal36

🏠
Working from home
View GitHub Profile
@xkal36
xkal36 / example.py
Last active October 19, 2018 11:31
def db_transaction(flush=False):
"""
Takes care of rolling back, committing and closing
session for decorated function.
"""
def wrap(f):
def wrapped_f(*args, **kwargs):
session = kwargs.get('session')
try:
result = f(*args, **kwargs)