aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGuilhem Moulin <guilhem@fripost.org>2024-06-03 16:24:09 +0200
committerGuilhem Moulin <guilhem@fripost.org>2024-06-03 17:57:56 +0200
commitdc4038860fd850dd08936dff64b124e41a2932a4 (patch)
tree14b3dd6bd09ffcfd17b6a50c5c606e5cc7c0ae64
parentf0894cc20c67c3f8505751b9b52c07ba9c786ed1 (diff)
webmap-download-mrr.py: Show number of WMS requests on exit.
(Incl. failure.)
-rw-r--r--webmap-download-mrr.py13
1 files changed, 13 insertions, 0 deletions
diff --git a/webmap-download-mrr.py b/webmap-download-mrr.py
index 1f44cf8..2d8612c 100644
--- a/webmap-download-mrr.py
+++ b/webmap-download-mrr.py
@@ -55,6 +55,17 @@ class WMS:
self.url = url
self.version = version
+ def __del__(self):
+ if self.req_count is not None and self.url is not None:
+ self.print_req_count()
+
+ def print_req_count(self, elapsed=None):
+ if elapsed is None:
+ logging.info('%d WMS requests sent to %s', self.req_count, self.url)
+ else:
+ logging.info('%d WMS requests (%.2f req/s) sent to %s', self.req_count,
+ self.req_count/elapsed, self.url)
+
# Send a request to the WMS server
def req(self, request, content_type=None, params={}, max_tries=10, timeout=10):
params2 = {
@@ -639,6 +650,8 @@ def download(dl, dest, dir_fd=None, headers={}, session=requests, progress=None)
raise e
elapsed = time_monotonic() - start
+ wms.print_req_count(elapsed=elapsed)
+ wms.req_count = None
logging.info('%s: Fetched %d features (%s) in %s (%.2f feat/s, %s/s)', dest,
feature_count, common.format_bytes(size),
common.format_time(elapsed),