def close_db(fn):
@wraps(fn)<EOL>def inner(*args, **kwargs):<EOL><INDENT>try:<EOL><INDENT>return fn(*args, **kwargs)<EOL><DEDENT>finally:<EOL><INDENT>if not HUEY.immediate:<EOL><INDENT>close_old_connections()<EOL><DEDENT><DEDENT><DEDENT>return inner<EOL>
Decorator to be used with tasks that may operate on the database.