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

Prevent files from being partially read from the cache #3819

Closed
wants to merge 1 commit into from

Conversation

ravenAtSafe
Copy link

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:

  • I have created a new test or updated the unit tests to cover the new/changed functionality.
  • I have updated CHANGES.txt (and read the README.rst)
  • I have updated the appropriate documentation

except:
pass

raise
Copy link
Contributor

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.

Copy link
Collaborator

@mwichmann mwichmann Oct 28, 2020

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')

Copy link
Collaborator

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.

@ravenAtSafe
Copy link
Author

ravenAtSafe commented Nov 13, 2020

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?

@mwichmann
Copy link
Collaborator

The tests aim at CacheRetrieve, which is the Action built up using CacheRetrieveFunc.

@ravenAtSafe
Copy link
Author

I agree, but also believe every CacheRetrieve test in CacheDirTests.py mocks out CacheRetrieveFunc so it ends up having no coverage. Am I misreading? Perhaps there is a better example test in there than I realize.

@bdbaddog bdbaddog mentioned this pull request Nov 24, 2020
3 tasks
@bdbaddog
Copy link
Contributor

Closing.
Continuing work in PR #3834

@bdbaddog bdbaddog closed this Nov 24, 2020
@ravenAtSafe ravenAtSafe deleted the partialCacheReadFix branch March 26, 2024 17:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants