@@ -495,23 +495,26 @@ def to_gigabytes(bytes_):
495
495
to_gigabytes (self .quota )))
496
496
497
497
# Quota not exceeded, print an informational message and return
498
- avg_size = size // count if count > 1 else 100 * 1024
499
- remaining = self .quota - size
500
- remaining_count = remaining / avg_size
501
- if remaining_count < 100 or float (remaining ) / self .quota < 0.1 :
502
- logger .warning ("Mongo Quota: %s %.3f / %.0f GB used" % (
503
- '.' .join ([self .database_name , self .library ]),
504
- to_gigabytes (size ),
505
- to_gigabytes (self .quota )))
506
- else :
507
- logger .info ("Mongo Quota: %s %.3f / %.0f GB used" % (
508
- '.' .join ([self .database_name , self .library ]),
509
- to_gigabytes (size ),
510
- to_gigabytes (self .quota )))
511
-
512
- # Set-up a timer to prevent us for checking for a few writes.
513
- # This will check every average half-life
514
- self .quota_countdown = int (max (remaining_count // 2 , 1 ))
498
+ try :
499
+ avg_size = size // count if count > 1 else 100 * 1024
500
+ remaining = self .quota - size
501
+ remaining_count = remaining / avg_size
502
+ if remaining_count < 100 or float (remaining ) / self .quota < 0.1 :
503
+ logger .warning ("Mongo Quota: %s %.3f / %.0f GB used" % (
504
+ '.' .join ([self .database_name , self .library ]),
505
+ to_gigabytes (size ),
506
+ to_gigabytes (self .quota )))
507
+ else :
508
+ logger .info ("Mongo Quota: %s %.3f / %.0f GB used" % (
509
+ '.' .join ([self .database_name , self .library ]),
510
+ to_gigabytes (size ),
511
+ to_gigabytes (self .quota )))
512
+
513
+ # Set-up a timer to prevent us for checking for a few writes.
514
+ # This will check every average half-life
515
+ self .quota_countdown = int (max (remaining_count // 2 , 1 ))
516
+ except Exception as e :
517
+ logger .warning ("Encountered an exception while calculating quota statistics: %s" % str (e ))
515
518
516
519
def get_library_type (self ):
517
520
return self .get_library_metadata (ArcticLibraryBinding .TYPE_FIELD )
0 commit comments