Commit 67856eaf authored by Antoine Millet's avatar Antoine Millet
Browse files

Added wait_timeout method on TunnelProtocol

parent 98cf0009
Loading
Loading
Loading
Loading
+13 −0
Original line number Diff line number Diff line
@@ -146,6 +146,19 @@ class TunnelProtocol(Protocol):
            self._cb_on_shutdown(self)
            super(TunnelProtocol, self).shutdown()

    def wait_shutdown(self, timeout=None, sig_timeout=1):
        """ Wait until tunnel has been shutdown.

        Return True if shutdown has been triggered, or False if timeout occurs.
        """
        if timeout is None:  # Workaround to avoid signal to be masked by Python
                             # while waiting the event.
            while True:
                if self._is_shutdown.wait(sig_timeout):
                    return True
        else:
            return self._is_shutdown.wait(timeout)

    def end_of_message(self):
        """ Handle inbound data from the :class:`RpcConnection` peer and place
            it on the incoming buffer.