From dc4038860fd850dd08936dff64b124e41a2932a4 Mon Sep 17 00:00:00 2001 From: Guilhem Moulin Date: Mon, 3 Jun 2024 16:24:09 +0200 Subject: webmap-download-mrr.py: Show number of WMS requests on exit. (Incl. failure.) --- webmap-download-mrr.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) 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), -- cgit v1.2.3