-
-
Notifications
You must be signed in to change notification settings - Fork 320
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
Prevent files from being partially read from the cache #3819
Conversation
except: | ||
pass | ||
|
||
raise |
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.
Raise what? The original exception from env.copy_from_cache or t.fs.unlink? This behaves differently in python2 and 3:
$ cat testexc.py
try:
raise ValueError
except:
try:
raise AttributeError
except:
pass
raise
$ python2.7 testexc.py
Traceback (most recent call last):
File "testexc.py", line 6, in <module>
raise AttributeError
AttributeError
$ python3.8 testexc.py
Traceback (most recent call last):
File "testexc.py", line 3, in <module>
raise ValueError
ValueError
I guess that this is what we're after:
$ cat testexc.py
try:
raise ValueError
except Exception as e1:
try:
raise AttributeError
except Exception as e2:
pass
finally:
raise e1
$ python2.7 testexc.py
Traceback (most recent call last):
File "testexc.py", line 10, in <module>
raise e1
ValueError
$ python3.8 testexc.py
Traceback (most recent call last):
File "testexc.py", line 10, in <module>
raise e1
File "testexc.py", line 3, in <module>
raise ValueError
ValueError
We should probably catch only the expected exceptions, and not all of them.
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.
We should probably catch only the expected exceptions, and not all of them.
indeed - the CI checks include linters on modified/added code, and the Sider checker is in fact complaining on these (E722 do not use bare 'except')
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.
Hmmm, an irritation here is we don't know for sure what the underlying retrieval method will be, due to layers of abstraction. It defaults to shutil.copy2
; shutil.copy
if the decider is timestamp-newer, but could presumably be changed.
Returning to this at last. While trying to add a unit test I found that there don't exist any unit tests for CacheRetrieveFunc, and perhaps with good reason due to the file IO? Should I forgo a unit test or mock up enough bits and pieces to make one? (I think it's possible, at least for my throwing case) Or I could move the fix into Taskmaster.py and test in way the existing unit tests work? |
The tests aim at |
I agree, but also believe every CacheRetrieve test in CacheDirTests.py mocks out |
Closing. |
This absolutely doesn't meet the standards presented in https://scons.org/guidelines.html
e.g. I'm working with SCons 3 and Python 2.7 on Linux so no testing with Python 3 or Windows
I'm open to tweaking CHANGES.txt and README.rst but I'm not sure I can get the time to add unit tests etc. (I have done very little SCons development so this is all fairly expensive for me to figure out.)
Contributor Checklist:
CHANGES.txt
(and read theREADME.rst
)