def close_on_error(read_meth):
 def new_read_meth(inst):
  try:
   return read_meth(inst)
  except httplib.HTTPException:
   inst.close()
   raise
 return new_read_meth

def close_on_error ( read_meth ) : def new_read_meth ( inst ) : try : return read_meth ( inst ) except httplib . HTTPException : inst . close ( ) raise return new_read_meth
decorator function .