statement, self._len = state
        self._query = Query(XCom.value).from_statement(text(statement))
    def __len__(self):
        if self._len is None:
            with self._get_bound_query() as query:
                self._len = query.count()
        return self._len
    def __iter__(self):
        return _LazyXComAccessIterator(self._get_bound_query())
    def __getitem__(self, key):
        if not isinstance(key, int):
            raise ValueError("only support index access for now")
        try:
            with self._get_bound_query() as query:
                r = query.offset(key).limit(1).one()
        except NoResultFound:
            raise IndexError(key) from None
        return XCom.deserialize_value(r)
    @contextlib.contextmanager
    def _get_bound_query(self) -> Generator[Query, None, None]:
        
        if self._query.session and self._query.session.is_active:
            yield self._query
            return
        session = settings.Session()
        try:
            yield self._query.with_session(session)
        finally:
            session.close()
def _patch_outdated_serializer(clazz: type[BaseXCom], params: Iterable[str]) -> None: