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

WIN/BF: When on Windows, close temporary files for further use #137

Merged
merged 1 commit into from
Nov 10, 2020

Conversation

adswa
Copy link
Member

@adswa adswa commented Nov 10, 2020

I tried to put my explorations from datalad/datalad#5138 into a PR. Running tests locally on Windows is a potpourri of errors, so pushed this hoping that the CI catches everything that I might have broken with this for other operating systems ;-)

@@ -44,6 +48,9 @@ def save(image, path):
# Use a temporary file because docker save (or actually tar underneath)
# complains that stdout needs to be redirected if we use Popen and PIPE.
with tempfile.NamedTemporaryFile() as stream:
if on_windows:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we really need to condition it with on_windows? sounds like it could just be generally done, or am I missing something?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, true. For some reason, I didn't think of this. Will adjust.

This adds a switch to explicitly close a temporary file created
by tempfile.NamedTemporaryFile().
tempfile not only creates a file, but also opens it.
While Unix system can write to a file that is opened by another process,
current Windows versions can't, and further use of the temporary file
in a subprocess results in Access Denied crashes.
For context, see github.com/datalad/datalad/issues/5138
Copy link
Contributor

@kyleam kyleam left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great, thanks!

@kyleam
Copy link
Contributor

kyleam commented Nov 10, 2020

I've cancelled one of the dup Travis builds.

@kyleam kyleam merged commit 52490c9 into master Nov 10, 2020
@kyleam kyleam deleted the win-5138 branch November 10, 2020 21:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants