Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2124)

Unified Diff: build/android/pylib/utils/device_temp_file.py

Issue 1311413002: Reland: Optimization: Make clean-up of DeviceTempFile() async (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@reland1
Patch Set: Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: build/android/pylib/utils/device_temp_file.py
diff --git a/build/android/pylib/utils/device_temp_file.py b/build/android/pylib/utils/device_temp_file.py
index 4623b9047bb37fc3b35fab4fc07dba834f509538..1364f7a7d93872fe757c2ca96e9ccb270781c1e3 100644
--- a/build/android/pylib/utils/device_temp_file.py
+++ b/build/android/pylib/utils/device_temp_file.py
@@ -6,6 +6,8 @@
# pylint: disable=W0622
+import threading
+
from pylib import cmd_helper
from pylib.device import device_errors
@@ -43,11 +45,16 @@ class DeviceTempFile(object):
def close(self):
"""Deletes the temporary file from the device."""
# ignore exception if the file is already gone.
- try:
- self._adb.Shell('rm -f %s' % self.name_quoted)
- except device_errors.AdbCommandFailedError:
- # file does not exist on Android version without 'rm -f' support (ICS)
- pass
+ def helper():
+ try:
+ self._adb.Shell('rm -f %s' % self.name_quoted, expect_status=None)
+ except device_errors.AdbCommandFailedError:
+ # file does not exist on Android version without 'rm -f' support (ICS)
+ pass
+
+ # It shouldn't matter when the temp file gets deleted, so do so
+ # asynchronously.
+ threading.Thread(target=helper).start()
def __enter__(self):
return self
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698