-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
CDK: allow repeated cache file removals & cleanup cache files in test #19533
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,2 @@ | ||
.coverage | ||
|
||
# TODO: these are tmp files generated by unit tests. They should go to the /tmp directory. | ||
cache_http_stream*.yml |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -68,11 +68,9 @@ def clear_cache(self): | |
""" | ||
remove cache file only once | ||
""" | ||
STREAM_CACHE_FILES = globals().setdefault("STREAM_CACHE_FILES", set()) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @grubberr tagging you since you had the git blame: why did this block only allow a single removal of the cache file? the current change is passing unit tests. Is that an issue? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @sherifnada oops I have answered on below |
||
if self.cache_filename not in STREAM_CACHE_FILES: | ||
with suppress(FileNotFoundError): | ||
os.remove(self.cache_filename) | ||
STREAM_CACHE_FILES.add(self.cache_filename) | ||
with suppress(FileNotFoundError): | ||
os.remove(self.cache_filename) | ||
print(f"Removed {self.cache_filename}") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This can be dangerous, for example:
I definitely remember there were some side-effects if we removed file not once There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We start to catch sqlite3 runtime exceptions There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @sherifnada let me cover that runtime side-effects with unit_tests today There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @sherifnada example of problem from
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I have dived into request_cache internals and it seems it happens something like this under the hood: #!/home/user/airbyte/airbyte-integrations/connectors/source-github/.venv/bin/python3
import os
import sqlite3
try:
os.unlink("cache.sqlite")
except FileNotFoundError:
pass
con = sqlite3.connect("cache.sqlite")
row = con.execute('CREATE TABLE t (col VARCHAR)')
con.commit()
os.unlink("cache.sqlite") # <- ATTENTION HERE
con.execute("INSERT INTO t (col) VALUES ('value')"); Traceback (most recent call last):
File "/home/user/airbyte/airbyte-integrations/connectors/source-github/./t.py", line 28, in <module>
con.execute("INSERT INTO t (col) VALUES ('value')");
sqlite3.OperationalError: attempt to write a readonly database |
||
|
||
@property | ||
@abstractmethod | ||
|
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.
0.9.5 since there is another PR claiming 0.9.4 already