Fix a ZeroDivisionError for short replicator runs.
During unittest runs it's possible for time.time() - self.start to be zero. This patch sets the elapsed value to an arbitrarily small number to prevent divide by zero errors. Change-Id: I20d4b9bf7ff3cdce4e9fe3215622c01cfec7f8bb
This commit is contained in:
@@ -455,7 +455,8 @@ class ObjectReplicator(Daemon):
|
||||
Logs various stats for the currently running replication pass.
|
||||
"""
|
||||
if self.replication_count:
|
||||
rate = self.replication_count / (time.time() - self.start)
|
||||
elapsed = (time.time() - self.start) or 0.000001
|
||||
rate = self.replication_count / elapsed
|
||||
self.logger.info(_("%(replicated)d/%(total)d (%(percentage).2f%%)"
|
||||
" partitions replicated in %(time).2fs (%(rate).2f/sec, "
|
||||
"%(remaining)s remaining)"),
|
||||
|
||||
Reference in New Issue
Block a user