def connectionLost(self, reason=connectionDone):
        """
        Mark the protocol as failed and fail all pending operations.
        """
        self._failed = reason
        pending, self._pending = self._pending, None
        for d in pending.values():
            d.errback(reason)