Conversation
| except OSError: | ||
| # Clean up streams if process creation fails | ||
| await read_stream.aclose() | ||
| await write_stream.aclose() | ||
| await read_stream_writer.aclose() | ||
| await write_stream_reader.aclose() | ||
| raise |
There was a problem hiding this comment.
It actually never triggers OSError here. anyio.open_process doesn't trigger.
Maybe the Windows logic does, but even if it does... The streams don't need to be closed because they are not even open yet, so just removing the except is fine.
There was a problem hiding this comment.
According to the test suite I'm wrong... I'm not sure how.
| await read_stream.aclose() | ||
| await write_stream.aclose() | ||
| await read_stream_writer.aclose() | ||
| await write_stream_reader.aclose() |
There was a problem hiding this comment.
No need to close read_stream and write_stream, just add the async context manager block above, and no need for read_stream_writer and write_stream_reader because they are open and closed within the tasks above.
There was a problem hiding this comment.
Well, it seems I was wrong... 👀
There was a problem hiding this comment.
Readability changes - I can revert if wanted.
This PR still doesn't solve the issue we have: if the process fails to start, it needs to raise. It doesn't. User is seeing
Client disconnectedmessage when runningclient.initialize().Maybe we can play with something like this in the task group (I'm not sure...):
It would be cool for
open_processto raise an exception onreturncode != None.