Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
path: root/Reflector.py
diff options
context:
space:
mode:
authorErich Eckner <git@eckner.net>2021-06-01 20:36:51 +0200
committerErich Eckner <git@eckner.net>2021-06-01 20:36:51 +0200
commit3e49ee9a9b9f517f0f53dbee73b498797cdec283 (patch)
tree0db182e0ddce8a26fbb0cac91c61cd0003305048 /Reflector.py
parent3ea727741ce79de6172441a22a7af7cfc9519371 (diff)
reflector-2020.12.7.1.tar.xz
Diffstat (limited to 'Reflector.py')
-rw-r--r--Reflector.py18
1 files changed, 14 insertions, 4 deletions
diff --git a/Reflector.py b/Reflector.py
index 95b6798..7b6b7ab 100644
--- a/Reflector.py
+++ b/Reflector.py
@@ -206,10 +206,20 @@ class DownloadTimer():
return self
def __exit__(self, typ, value, traceback):
- self.time = time.time() - self.start_time
+ time_delta = time.time() - self.start_time
+ signal.alarm(0)
+ self.time = time_delta
if self.timeout > 0:
signal.signal(signal.SIGALRM, self.previous_handler)
- signal.alarm(self.previous_timer)
+
+ previous_timer = self.previous_timer
+ if previous_timer > 0:
+ remaining_time = int(previous_timer - time_delta)
+ # The alarm should have been raised during the download.
+ if remaining_time <= 0:
+ signal.raise_signal(signal.SIGALRM)
+ else:
+ signal.alarm(remaining_time)
self.start_time = None
@@ -276,7 +286,7 @@ def rate_rsync(
DownloadTimeout
) as err:
logger = get_logger()
- logger.info('failed to rate rsync download (%s): %s', db_url, err)
+ logger.warning('failed to rate rsync download (%s): %s', db_url, err)
return 0, 0
@@ -304,7 +314,7 @@ def rate_http(
DownloadTimeout
) as err:
logger = get_logger()
- logger.info('failed to rate http(s) download (%s): %s', db_url, err)
+ logger.warning('failed to rate http(s) download (%s): %s', db_url, err)
return 0, 0