File tree Expand file tree Collapse file tree 1 file changed +5
-6
lines changed
src/claude_code_sdk/_internal/transport Expand file tree Collapse file tree 1 file changed +5
-6
lines changed Original file line number Diff line number Diff 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 :
You can’t perform that action at this time.
0 commit comments