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

path/filepath: add Glob variant taking a context.Context? #16448

Closed
bradfitz opened this issue Jul 20, 2016 · 7 comments
Closed

path/filepath: add Glob variant taking a context.Context? #16448

bradfitz opened this issue Jul 20, 2016 · 7 comments

Comments

@bradfitz
Copy link
Contributor

From internal bug report:

filepath.Glob can take a lot of time, and can't be canceled.

Add a Context variant?

@bradfitz bradfitz added this to the Go1.8 milestone Jul 20, 2016
@robpike
Copy link
Contributor

robpike commented Jul 20, 2016

That seems like a domain-crossing change. It makes me uncomfortable. Lots of things take a long time, and it would be lousy if every possible long-running operation got a Context variant.

@luna-duclos
Copy link

Perhaps a more general cancellation mechanism than contexts is in order ? It'd be very nice if most long running operations in Go could be cancelled, but I don't think context is the right tool for the job.

@minux
Copy link
Member

minux commented Jul 20, 2016 via email

@ianlancetaylor
Copy link
Contributor

Now that we have the context package in the standard library, I don't think we want to introduce another, different, cancellation mechanism.

I don't know but I wouldn't guess that the problem is the system call. I suspect the problem is that Glob is being used to traverse a large directory tree.

I don't think it makes sense to add a context.Context argument to Glob, though. If it's really necessary to cancel the directory traversal, then I think Glob is probably the wrong function to call. The program should call a different function that streams the files to a channel (and takes a Context argument). I don't know that that function belongs in the standard library.

@mdempsky
Copy link
Contributor

@minux POSIX says all file system calls that block indeterminately due to waiting on the underlying disk/network storage device are interruptible (though I would expect in practice that kernel bugs and things like FUSE regularly break that).

@minux
Copy link
Member

minux commented Jul 20, 2016 via email

@bradfitz
Copy link
Contributor Author

Yeah, I assumed our glob supported "**" when I filed the bug because I remembered #11862 and thought it was already fixed.

We can do nothing here. The internal Google glob can be fixed instead.

@golang golang locked and limited conversation to collaborators Jul 20, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

7 participants