Skip to content
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

Support I/O cancellation #23

Open
lukechampine opened this issue Dec 13, 2019 · 1 comment
Open

Support I/O cancellation #23

lukechampine opened this issue Dec 13, 2019 · 1 comment
Assignees
Labels
enhancement New feature or request renter

Comments

@lukechampine
Copy link
Owner

It should be possible to cancel PseudoFile operations like Read and Write. This would imply support for cancellation at the proto level as well.

I think the best way to accomplish this would be SetDeadline methods on PseudoFile and Session. These would translate directly to SetDeadline calls on the underlying net.Conn. If a timeout occurs, the caller should be able to determine this by unwrapping the resulting error.

Adding context.Context arguments to every method is also an option, but I've never liked this pattern. It pollutes the API and drags in non-cancellation baggage that is almost never used.

@lukechampine lukechampine self-assigned this Dec 13, 2019
@lukechampine lukechampine added enhancement New feature or request renter labels Dec 13, 2019
@jkawamoto
Copy link
Contributor

It's not easy to implement graceful shutdown without context-based cancellation, isn't it?

On the other hand, from this discussion, we should use a longer timeout such as a couple of minutes: https://discordapp.com/channels/341359001797132308/341362900117487636/740999604169998436

Then, SetDeadline-based cancellation would block a goroutine for a long time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request renter
Projects
None yet
Development

No branches or pull requests

2 participants