Skip to content

Commit 055d60f

Browse files
dicksontsairushilpatel0
authored andcommitted
Finalize streaming impl
Signed-off-by: Rushil Patel <[email protected]>
1 parent c0841d8 commit 055d60f

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

src/claude_code_sdk/_internal/transport/subprocess_cli.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -167,8 +167,9 @@ async def connect(self) -> None:
167167
# Streaming mode: keep stdin open and start streaming task
168168
if self._process.stdin:
169169
self._stdin_stream = TextSendStream(self._process.stdin)
170-
# Start streaming messages to stdin
171-
anyio.start_soon(self._stream_to_stdin)
170+
# Start streaming messages to stdin in background
171+
import asyncio
172+
asyncio.create_task(self._stream_to_stdin())
172173
else:
173174
# String mode: close stdin immediately (backward compatible)
174175
if self._process.stdin:
@@ -219,10 +220,8 @@ async def _stream_to_stdin(self) -> None:
219220
break
220221
await self._stdin_stream.send(json.dumps(message) + "\n")
221222

222-
# Close stdin when done
223-
if self._stdin_stream:
224-
await self._stdin_stream.aclose()
225-
self._stdin_stream = None
223+
# Signal EOF but keep the stream open for control messages
224+
# This matches the TypeScript implementation which calls stdin.end()
226225
except Exception as e:
227226
logger.debug(f"Error streaming to stdin: {e}")
228227
if self._stdin_stream:

0 commit comments

Comments
 (0)