From 1f8f4c8cfeaf02754f3259f9eb811ada0ed3499e Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Fri, 21 Feb 2020 11:00:11 +0100 Subject: Codesign: Make file watcher robust for network errors --- .../buildbot/codesign/archive_with_indicator.py | 28 ++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) (limited to 'build_files') diff --git a/build_files/buildbot/codesign/archive_with_indicator.py b/build_files/buildbot/codesign/archive_with_indicator.py index d1af207df83..085026fcf98 100644 --- a/build_files/buildbot/codesign/archive_with_indicator.py +++ b/build_files/buildbot/codesign/archive_with_indicator.py @@ -70,8 +70,12 @@ class ArchiveWithIndicator: self.archive_filepath = self.base_dir / archive_name self.ready_indicator_filepath = self.base_dir / ready_indicator_name - def is_ready(self) -> bool: - """Check whether the archive is ready for access.""" + def is_ready_unsafe(self) -> bool: + """ + Check whether the archive is ready for access. + + No guarding about possible network failres is done here. + """ if not self.ready_indicator_filepath.exists(): return False @@ -105,6 +109,26 @@ class ArchiveWithIndicator: return True + def is_ready(self) -> bool: + """ + Check whether the archive is ready for access. + + Will tolerate possible network failures: if there is a network failure + or if there is still no proper permission on a file False is returned. + """ + + # There are some intermitten problem happening at a random which is + # translates to "OSError : [WinError 59] An unexpected network error occurred". + # Some reports suggests it might be due to lack of permissions to the file, + # which might be applicable in our case since it's possible that file is + # initially created with non-accessible permissions and gets chmod-ed + # after initial creation. + try: + return self.is_ready_unsafe() + except OSError as e: + print(f'Exception checking archive: {e}') + return False + def tag_ready(self) -> None: """ Tag the archive as ready by creating the corresponding indication file. -- cgit v1.2.3