def scoped_connection(func):
  '''
  Decorator that gives out connections.
  '''
  def _with(series, *args, **kwargs):
    connection = None
    try:
      connection = series._connection()
      return func(series, connection, *args, **kwargs)
    finally:
      series._return( connection )
  return _with
def scoped_connection ( func ) : def _with ( series , * args , ** kwargs ) : connection = None try : connection = series . _connection ( ) return func ( series , connection , * args , ** kwargs ) finally : series . _return ( connection ) return _with
Decorator that gives out connections.