Commit 067ba1ad authored by Jondy Zhao's avatar Jondy Zhao

netdrive: change sleep interval

parent c684523c
...@@ -86,7 +86,7 @@ class NetDriveUsageReporter(object): ...@@ -86,7 +86,7 @@ class NetDriveUsageReporter(object):
self.report_interval = float(self.report_interval) self.report_interval = float(self.report_interval)
self.initializeDatabase(self.data_file) self.initializeDatabase(self.data_file)
def initializeConnection(self): def initializeConnection(self):
connection_dict = {} connection_dict = {}
connection_dict['key_file'] = self.key_file connection_dict['key_file'] = self.key_file
connection_dict['cert_file'] = self.cert_file connection_dict['cert_file'] = self.cert_file
...@@ -117,12 +117,13 @@ class NetDriveUsageReporter(object): ...@@ -117,12 +117,13 @@ class NetDriveUsageReporter(object):
self.sendAllReport() self.sendAllReport()
self.initializeConnection() self.initializeConnection()
last_timestamp = datetime.now() last_timestamp = datetime.now()
interval = 30.0 if self.report_interval > 60 else (self.report_interval / 2)
try: try:
while True: while True:
current_timestamp = datetime.now() current_timestamp = datetime.now()
d = current_timestamp - last_timestamp d = current_timestamp - last_timestamp
if d.seconds < self.report_interval: if d.seconds < self.report_interval:
sleep(self.report_interval) sleep(interval)
continue continue
self.insertUsageReport(last_timestamp.isoformat(), d.seconds) self.insertUsageReport(last_timestamp.isoformat(), d.seconds)
self.sendReport() self.sendReport()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment