def socket_exception(func):
 def read(self, *args, **kwargs):
  try:
   return func(self, *args, **kwargs)
  except socket.error:
   self.close()
 return read

def socket_exception ( func ) : def read ( self , * args , ** kwargs ) : try : return func ( self , * args , ** kwargs ) except socket . error : self . close ( ) return read
decorator close object on socket .