def create_session(self):
        try:
            session_id = self._used_ids_ba.index(False)
        except __HOLE__:
            raise Error("Can't create more MARS sessions, close some sessions and try again")
        session = _SmpSession(self, session_id)
        with self._lock:
            self._sessions[session_id] = session
            self._used_ids_ba[session_id] = True
            hdr = self._smp_header.pack(
                self._smid,
                self._SYN,
                session_id,
                self._smp_header.size,
                0,
                session._high_water_for_recv,
                )
            self._transport.send(hdr, True)
            session._state = 'SESSION ESTABLISHED'
        return session
dataset/ETHPy150Open denisenkom/pytds/pytds/smp.py/SmpManager.create_session