-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Fix issue 7280 - issue warning after retry #7546
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
Closed
Closed
Changes from all commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
ae887ac
Addresses #7280 - More targeted fix to problem
b90cc2c
Address #7280 - Add issue description file
942ab14
Hardening test cases for #7280
cce077f
Fix issue #7280 - capture error and warn, but retry as normal
b6c0991
Update news entry for #7280 to be more complete.
eb73752
Issue #7280 - Clean-up python2.7, isort, and flake8 errors
fc5450f
Fix #7280 - address Python2.7 issues resulting from PEP 3151
cb1a787
Fix #7280 - another attempt to satisfy older versions of Python
0fb324b
Issue #7280 - Attempt to address failing python2.7 test
8770497
Fix #7280 - make test code more DRY
68eb8d4
Merge branch 'master' of github.com:pypa/pip into 7280-alt-3
a2d8650
Fix issue #7280 - capture error and warn, but retry as normal
d00958d
Merge branch '7280-alt-3' of github.com:danizen/pip into 7280-alt-3
3ed7733
Address requests changed in pull request
b0216be
Assert something about the error raised for windows
38e6d41
Update test that this produces an Exception
aadefd6
Update pull request for linter errors
40bf93a
Clean-up expected errors and exceptions
5be7b66
Be more forceful about terminating a joined thread if it is still alive.
17246e7
Restore news/7280.bugfix - we'll need a separate issue to decouple this.
88dffb1
Merge branch 'master' of github.com:pypa/pip into 7280-temp-dir
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
When pip is installing or removing a package and is unable to remove a temporary directory on Windows, | ||
this is likely due to a Virus Scan operation. This fix warns the user and continues rather than | ||
preventing the operation. pip still retries the removal, so this happens quite rarely in most Windows | ||
environments. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
import errno | ||
import os | ||
import shutil | ||
|
||
import psutil | ||
import pytest | ||
|
||
from tests.lib.filesystem import FileOpener | ||
|
||
skip_unless_windows = pytest.mark.skipif("sys.platform != 'win32'") | ||
|
||
|
||
@pytest.fixture() | ||
def process(): | ||
return psutil.Process() | ||
|
||
|
||
def test_file_opener_no_file(process): | ||
# FileOpener joins the subprocess even if the parent never sends the path | ||
with FileOpener(): | ||
assert len(process.children()) == 1 | ||
assert len(process.children()) == 0 | ||
|
||
|
||
def test_file_opener_not_found(tmpdir, process): | ||
# The FileOpener cleans up the subprocess when the file cannot be opened | ||
path = tmpdir.joinpath('foo.txt') | ||
with FileOpener(path): | ||
assert len(process.children()) == 1 | ||
assert len(process.children()) == 0 | ||
|
||
|
||
def test_file_opener_normal(tmpdir, process): | ||
# The FileOpener cleans up the subprocess when the file exists | ||
path = tmpdir.joinpath('foo.txt') | ||
path.write_text('Hello') | ||
with FileOpener(path): | ||
assert len(process.children()) == 1 | ||
assert len(process.children()) == 0 | ||
|
||
|
||
@skip_unless_windows | ||
def test_file_opener_produces_unlink_error(tmpdir, process): | ||
# FileOpener forces an error on Windows when we attempt to remove a file | ||
# The initial path may be deferred; which must be tested with an error | ||
path = tmpdir.joinpath('foo.txt') | ||
path.write_text('Hello') | ||
with FileOpener() as opener: | ||
opener.send(path) | ||
with pytest.raises(OSError) as e: | ||
os.unlink(path) | ||
assert e.value.errno == errno.EACCES | ||
|
||
|
||
@skip_unless_windows | ||
def test_file_opener_produces_rmtree_error(tmpdir, process): | ||
subdir = tmpdir.joinpath('foo') | ||
os.mkdir(subdir) | ||
path = subdir.joinpath('bar.txt') | ||
path.write_text('Hello') | ||
with FileOpener(path): | ||
with pytest.raises(OSError) as e: | ||
shutil.rmtree(subdir) | ||
assert e.value.errno == errno.EACCES |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Instead of manually tracking the file and connection we can use
ExitStack
andclosing
which are available inpip._vendor.contextlib2
, like: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.
This suggested change did not work for me, and caused the sub-process or main process to hang. In general, I liked it more that the sub-process was using primitive parts of Python, and was independent of pip's own infrastructure, so I thought I'd raise that as a good thing before we potentially figure out what I did wrong :)