jedcunningham commented on code in PR #22849:
URL: https://github.com/apache/airflow/pull/22849#discussion_r846639474
##########
airflow/models/taskinstance.py:
##########
@@ -295,6 +299,71 @@ def clear_task_instances(
dr.start_date = None
+class _LazyXComAccessIterator(collections.abc.Iterator):
+ __slots__ = ['_cm', '_it']
+
+ def __init__(self, cm: ContextManager[Query]):
+ self._cm = cm
+ self._it = None
+
+ def __del__(self):
+ if self._it:
+ self._cm.__exit__(None, None, None)
+
+ def __iter__(self):
+ return self
+
+ def __next__(self):
+ if not self._it:
+ self._it = iter(self._cm.__enter__())
+ return XCom.deserialize_value(next(self._it))
+
+
+class _LazyXComAccess(collections.abc.Sequence):
+ """Wrapper to lazily pull XCom with a sequence-like interface.
+
+ Note that since the session bound to the parent query may have died when we
+ actually access the sequence's content, we must a new fresh session
Review Comment:
```suggestion
actually access the sequence's content, we must create a new session
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]