]> git.openstreetmap.org Git - nominatim.git/blobdiff - nominatim/indexer/progress.py
Merge remote-tracking branch 'upstream/master'
[nominatim.git] / nominatim / indexer / progress.py
index c9d8816be989fb99675341a512c6806efcf06465..b758e10d52abce50da267df4953803dbf67e36eb 100644 (file)
@@ -1,7 +1,9 @@
 # SPDX-License-Identifier: GPL-2.0-only
 #
 # SPDX-License-Identifier: GPL-2.0-only
 #
-# This file is part of Nominatim.
-# Copyright (C) 2020 Sarah Hoffmann
+# This file is part of Nominatim. (https://nominatim.org)
+#
+# Copyright (C) 2022 by the Nominatim developer community.
+# For a full list of authors see the git log.
 """
 Helpers for progress logging.
 """
 """
 Helpers for progress logging.
 """
@@ -57,8 +59,14 @@ class ProgressLogger:
         """ Print final statistics about the progress.
         """
         rank_end_time = datetime.now()
         """ Print final statistics about the progress.
         """
         rank_end_time = datetime.now()
-        diff_seconds = (rank_end_time-self.rank_start_time).total_seconds()
+
+        if rank_end_time == self.rank_start_time:
+            diff_seconds = 0
+            places_per_sec = self.done_places
+        else:
+            diff_seconds = (rank_end_time - self.rank_start_time).total_seconds()
+            places_per_sec = self.done_places / diff_seconds
 
         LOG.warning("Done %d/%d in %d @ %.3f per second - FINISHED %s\n",
                     self.done_places, self.total_places, int(diff_seconds),
 
         LOG.warning("Done %d/%d in %d @ %.3f per second - FINISHED %s\n",
                     self.done_places, self.total_places, int(diff_seconds),
-                    self.done_places/diff_seconds, self.name)
+                    places_per_sec, self.name)