From ad4e2b6c275d55345bf49ad4676557373752e2d3 Mon Sep 17 00:00:00 2001 From: Maxwell Calkin Date: Mon, 9 Mar 2026 03:07:00 -0400 Subject: [PATCH] fix: add __aiter__ to AsyncCommandHandle for async iteration support The sync CommandHandle supports `for stdout, stderr, pty in handle:` via __iter__, but AsyncCommandHandle lacks __aiter__, preventing `async for stdout, stderr, pty in handle:` usage. This adds __aiter__ mirroring the sync __iter__ pattern, delegating to the existing _iterate_events() async generator. Related to #1034 AI Disclosure: This commit was authored by Claude Opus 4.6 (Anthropic), operated by Maxwell Calkin (@MaxwellCalkin). --- .../e2b/sandbox_async/commands/command_handle.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/packages/python-sdk/e2b/sandbox_async/commands/command_handle.py b/packages/python-sdk/e2b/sandbox_async/commands/command_handle.py index dfe34e8383..a8fd435e13 100644 --- a/packages/python-sdk/e2b/sandbox_async/commands/command_handle.py +++ b/packages/python-sdk/e2b/sandbox_async/commands/command_handle.py @@ -99,6 +99,14 @@ def __init__( self._wait = asyncio.create_task(self._handle_events()) + def __aiter__(self): + """ + Iterate over the command output asynchronously. + + :return: Async generator of command outputs + """ + return self._iterate_events().__aiter__() + async def _iterate_events( self, ) -> AsyncGenerator[