def __init__(self, host, port, connect_timeout, buf_size):
        """
        :param host: hostname or IP address
        :param port: port
        :param connect_timeout: connect timeout
        :type host: str
        :type port: int
        :type connect_timeout: float or None
        """
        self._rbuf = bytearray(buf_size)

        #: :type: datetime.datetime
        self.last_heartbeat_sent = None
        #: :type: datetime.datetime
        self.last_heartbeat_received = None

        self.last_heartbeat_sent_monotonic = 0.0

        # the purpose of the frame lock is to allow no more than one thread to read/write a frame
        # to the connection at any time
        self._frame_write_lock = RLock()
        self._frame_read_lock = RLock()

        self.sock = None

        # try to connect
        last_err = None
        for res in socket.getaddrinfo(host, port, 0, socket.SOCK_STREAM, socket.IPPROTO_TCP):
            af, socktype, proto, canonname, sa = res
            try:
                self.sock = socket.socket(af, socktype, proto)
                self.sock.settimeout(connect_timeout)
                self.sock.connect(sa)
                break
            except socket.error as exc:
                self.sock.close()
                self.sock = None
                last_err = exc

        if not self.sock:
            # didn't connect, return the most recent error message
            raise socket.error(last_err)

        try:
            assert isinstance(self.sock, socket.socket)
            self.sock.settimeout(None)
            self.sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1)
            self.sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1)

            self._setup_transport()

            self.write(AMQP_PROTOCOL_HEADER)
        except (OSError, IOError, socket.error) as exc:
            if _UNAVAIL not in get_errno(exc):
                self.connected = False
            raise

        self.connected = True
dataset/ETHPy150Open veegee/amqpy/amqpy/transport.py/Transport.__init__/swapped operands of `not in`