def _wrap_transport(method):
 @functools.wraps(method)
 def wrapper(self, *args, **kwargs):
  self._check_stream()
  self._stream.set_close_callback(functools.partial(self._on_close, gr=greenlet.getcurrent()))
  self._start_time = time.time()
  timeout = self._set_timeout()
  try:
   return method(self, *args, **kwargs)
  except TTransportException:
   self.close()
   raise
  finally:
   self._clear_timeout(timeout)
   if self._stream:
    self._stream.set_close_callback(functools.partial(self._on_close, gr=None))
 return wrapper

def _wrap_transport ( method ) : @ functools . wraps ( method ) def wrapper ( self , * args , ** kwargs ) : self . _check_stream ( ) self . _stream . set_close_callback ( functools . partial ( self . _on_close , gr = greenlet . getcurrent ( ) ) ) self . _start_time = time . time ( ) timeout = self . _set_timeout ( ) try : return method ( self , * args , ** kwargs ) except TTransportException : self . close ( ) raise finally : self . _clear_timeout ( timeout ) if self . _stream : self . _stream . set_close_callback ( functools . partial ( self . _on_close , gr = None ) ) return wrapper
decorator to consistently check the underlying stream .