def _recv_packet(self, session):
        with self._lock:
            if session._state == 'CLOSED':
                return b''
            while not session._recv_queue:
                self._read_smp_message()
                if session._state in ('CLOSED', 'FIN RECEIVED'):
                    return b''
            session._high_water_for_recv = self._add_one_wrap(session._high_water_for_recv)
            if session._high_water_for_recv - session._last_high_water_for_recv >= 2:
                hdr = self._smp_header.pack(
                    self._smid,
                    self._ACK,
                    session._session_id,
                    self._smp_header.size,
                    session._seq_num_for_send,
                    session._high_water_for_recv,
                    )
                self._transport.send(hdr, True)
                session._last_high_water_for_recv = session._high_water_for_recv
            return session._recv_queue.pop(0)
dataset/ETHPy150Open denisenkom/pytds/pytds/smp.py/SmpManager._recv_packet/original