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

Fix: pop current directory after chdir. #803

Merged
merged 2 commits into from
Oct 26, 2021

Conversation

dblock
Copy link
Member

@dblock dblock commented Oct 25, 2021

Signed-off-by: dblock dblock@dblock.org

Description

On Windows deleting the current directory fails with a "this directory is used by another process" error. Move chdir into TemporaryDirectory as an option and pop it.

Issues Resolved

An error similar to #774 but reproduced more consistently.

Check List

  • Commits are signed per the DCO using --signoff

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.

@codecov-commenter
Copy link

codecov-commenter commented Oct 25, 2021

Codecov Report

Merging #803 (197d497) into main (bb17922) will increase coverage by 0.08%.
The diff coverage is 92.85%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #803      +/-   ##
==========================================
+ Coverage   90.75%   90.84%   +0.08%     
==========================================
  Files          78       78              
  Lines        2164     2162       -2     
==========================================
  Hits         1964     1964              
+ Misses        200      198       -2     
Impacted Files Coverage Δ
src/run_perf_test.py 0.00% <0.00%> (ø)
src/manifests_workflow/input_manifests.py 98.55% <100.00%> (-0.03%) ⬇️
src/run_assemble.py 97.05% <100.00%> (-0.09%) ⬇️
src/run_build.py 84.61% <100.00%> (-0.39%) ⬇️
src/run_checkout.py 95.23% <100.00%> (-0.22%) ⬇️
src/run_ci.py 81.81% <100.00%> (-0.54%) ⬇️
src/run_integ_test.py 95.65% <100.00%> (-0.10%) ⬇️
src/system/temporary_directory.py 96.55% <100.00%> (+0.89%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update bb17922...197d497. Read the comment docs.

Signed-off-by: dblock <dblock@dblock.org>
Signed-off-by: dblock <dblock@amazon.com>
if chdir:
self.curdir = os.getcwd()
os.chdir(self.name)
else:
Copy link
Member

@owaiskazi19 owaiskazi19 Oct 26, 2021

Choose a reason for hiding this comment

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

nit:

Suggested change
else:
self.curdir = None
if chdir:
self.curdir = os.getcwd()
os.chdir(self.name)

Copy link
Member Author

Choose a reason for hiding this comment

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

I personally don't love this because it assigns self.curdir twice.

@dblock dblock merged commit 27bef02 into opensearch-project:main Oct 26, 2021
@dblock dblock deleted the fix-temp-delete branch October 26, 2021 10:16
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.

5 participants