-
Notifications
You must be signed in to change notification settings - Fork 40
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Raise EOF when writing to a closed sandbox over the network #2330
Conversation
modal/io_streams.py
Outdated
) | ||
except GRPCError as exc: | ||
if exc.status == Status.FAILED_PRECONDITION: | ||
raise EOFError("Stdin is closed. Cannot write to it.") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can't you grab the message in the gRPC exception? It'd be more accurate and forward compatible.
Also not sure EOFError
is what a user should expect here, could we instead throw an exception from within the modal.exception
namespace that is like 'invalid error'?
Also re-reading the docstring I don't like that it suggests that drain()
may always send EOF. It'd be nice to reword that to indicate EOF is only sent once the writer is closed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed the comments and switched to ValueError to match python native socket behavior.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Have some alternative ideas about the appropriate error-handling here, and also think this error-handling functionality is important enough to warrant a basic unit test 👍
69768ac
to
6a1fad6
Compare
@thundergolfer I added a test |
6a1fad6
to
f5b6d1b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
modal/io_streams.py
Outdated
) | ||
except GRPCError as exc: | ||
if exc.status == Status.FAILED_PRECONDITION: | ||
raise ValueError("I/O operation on closed file.") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would still prefer if the client relied on the message from the server because in the future there could be multiple ways of receiving a FAILED_PRECONDITION
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok ser
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wait can I convince you otherwise on this - I want to match the exact error that Python throws on close FDs for close API compatibility, but I don't think it makes sense for the RPC to throw this. I think the separation is valuable here, for the same reason that we don't throw FAILED_PRECONDITION back to the user.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok boss you convinced me
2b35347
to
b846ece
Compare
@prbot automerge |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some required workflows are pending. Will automerge once they complete successfully. Please bear with us in this difficult time.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cannot automerge PR because workflow 'CI / CD' failed.
This feature works again.
b846ece
to
dcfe25b
Compare
Describe your changes
If Stdin is closed (particularly relevant for sandboxes), and EOF error will be throw instead of accepting the write.
Backward/forward compatibility checks
Check these boxes or delete any item (or this section) if not relevant for this PR.
Note on protobuf: protobuf message changes in one place may have impact to
multiple entities (client, server, worker, database). See points above.
Changelog
When writing to a
StreamWriter
that has already had EOF written, a ValueError is now raised instead of anEOFError
.