Skip to content

Commit

Permalink
fix temp file deletion issue
Browse files Browse the repository at this point in the history
  • Loading branch information
aaronsteers committed Mar 18, 2024
1 parent 4524d75 commit c581b6b
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions airbyte/sources/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,12 @@


@contextmanager
def as_temp_files(files_contents: list[Any]) -> Generator[list[str], Any, None]:
def as_temp_files(files_contents: list[dict | str]) -> Generator[list[str], Any, None]:
"""Write the given contents to temporary files and yield the file paths as strings."""
temp_files: list[Any] = []
try:
for content in files_contents:
temp_file = tempfile.NamedTemporaryFile(mode="w+t", delete=True)
temp_file = tempfile.NamedTemporaryFile(mode="w+t", delete=False)
temp_file.write(
json.dumps(content) if isinstance(content, dict) else content,
)
Expand All @@ -61,7 +61,7 @@ def as_temp_files(files_contents: list[Any]) -> Generator[list[str], Any, None]:
finally:
for temp_file in temp_files:
with suppress(Exception):
temp_file.close()
temp_file.unlink()


class Source:
Expand Down

0 comments on commit c581b6b

Please sign in to comment.