def _close_smp_session(self, session):
        if session._state in ('CLOSED', 'FIN SENT'):
            return
        elif session._state == 'SESSION ESTABLISHED':
            with self._lock:
                if self._transport.is_connected():
                    hdr = self._smp_header.pack(
                        self._smid,
                        self._FIN,
                        session._session_id,
                        self._smp_header.size,
                        session._seq_num_for_send,
                        session._high_water_for_recv,
                        )
                    session._state = 'FIN SENT'
                    try:
                        self._transport.send(hdr, True)
                        self._recv_packet(session)
                    except (socket.error, OSError) as ex:
                        if (errno.ECONNRESET, errno.EPIPE) in ex.errno:
                            session._state = 'CLOSED'
                        else:
                            raise ex
                else:
                    session._state = 'CLOSED'
dataset/ETHPy150Open denisenkom/pytds/pytds/smp.py/SmpManager._close_smp_session/swapped operands of `in`