mirror of
https://github.com/ARM-software/workload-automation.git
synced 2025-09-04 20:32:36 +01:00
fw: Replace usage of file locking with atomic writes
To prevent long timeouts occurring during to file locking on both reads and writes replace locking with atomic writes. While this may results in cache entries being overwritten, the amount of time used in duplicated retrievals will likely be saved with the prevention of stalls due to waiting to acquire the file lock.
This commit is contained in:
@@ -23,7 +23,7 @@ from devlib.utils.android import AndroidProperties
|
||||
from wa.framework.configuration.core import settings
|
||||
from wa.framework.exception import ConfigError
|
||||
from wa.utils.serializer import read_pod, write_pod, Podable
|
||||
from wa.utils.misc import lock_file
|
||||
from wa.utils.misc import atomic_write_path
|
||||
|
||||
|
||||
def cpuinfo_from_pod(pod):
|
||||
@@ -281,15 +281,14 @@ def read_target_info_cache():
|
||||
os.makedirs(settings.cache_directory)
|
||||
if not os.path.isfile(settings.target_info_cache_file):
|
||||
return {}
|
||||
with lock_file(settings.target_info_cache_file):
|
||||
return read_pod(settings.target_info_cache_file)
|
||||
return read_pod(settings.target_info_cache_file)
|
||||
|
||||
|
||||
def write_target_info_cache(cache):
|
||||
if not os.path.exists(settings.cache_directory):
|
||||
os.makedirs(settings.cache_directory)
|
||||
with lock_file(settings.target_info_cache_file):
|
||||
write_pod(cache, settings.target_info_cache_file)
|
||||
with atomic_write_path(settings.target_info_cache_file) as at_path:
|
||||
write_pod(cache, at_path)
|
||||
|
||||
|
||||
def get_target_info_from_cache(system_id, cache=None):
|
||||
|
Reference in New Issue
Block a user