From b51ae5c2c4fc540e3ea5b784dc9580e19d1d84f4 Mon Sep 17 00:00:00 2001 From: Alan Hamlett Date: Wed, 6 May 2015 12:22:42 -0700 Subject: [PATCH] don't send two write heartbeats within 2 seconds of eachother --- WakaTime.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/WakaTime.py b/WakaTime.py index 52af20d..ab6ec28 100644 --- a/WakaTime.py +++ b/WakaTime.py @@ -136,9 +136,11 @@ def obfuscate_apikey(command_list): return cmd -def enough_time_passed(now, last_time): +def enough_time_passed(now, last_time, is_write): if now - last_time > ACTION_FREQUENCY * 60: return True + if is_write and now - last_time > 2: + return True return False @@ -201,7 +203,7 @@ class SendActionThread(threading.Thread): with self.lock: if self.target_file: self.timestamp = time.time() - if self.force or (self.is_write and not self.last_action['is_write']) or self.target_file != self.last_action['file'] or enough_time_passed(self.timestamp, self.last_action['time']): + if self.force or self.target_file != self.last_action['file'] or enough_time_passed(self.timestamp, self.last_action['time'], self.is_write): self.send_heartbeat() def send_heartbeat(self):