Skip to content

Commit 62d25e0

Browse files
kenjitoyamacopybara-github
authored andcommitted
Pass delete_on_close=False to NamedTemporaryFile().
The behavior of [`NamedTemporaryFile()`](https://docs.python.org/3/library/tempfile.html#tempfile.NamedTemporaryFile) is slightly different on Windows when the file is accessed multiple times in the same context manager. `delete_on_close=False` allows the file to exist until the end of the context manager, which is the behavior we want in all platforms. Please see PR #265 for details (and thanks to @NingLi670 for opening the original PR). PiperOrigin-RevId: 732946651
1 parent b8e0d77 commit 62d25e0

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

android_env/components/adb_call_parser.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,11 @@ def _install_apk(
280280
['install', '-r', '-t', '-g', fpath], timeout=timeout
281281
)
282282
case 'blob':
283-
with tempfile.NamedTemporaryFile(suffix='.apk') as f:
283+
# fmt: off
284+
with tempfile.NamedTemporaryFile(
285+
suffix='.apk', delete_on_close=False
286+
) as f:
287+
# fmt: on
284288
fpath = f.name
285289
f.write(install_apk.blob.contents)
286290

0 commit comments

Comments
 (0)