Skip to content

Commit f6c908f

Browse files
committed
Simplify delay time calculation.
Would still be far easier timedelta.total_seconds(), but Python <2.7 compatibility denies us that luxury.
1 parent 4bb1f50 commit f6c908f

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

github2/request.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -175,10 +175,9 @@ def delete(self, *path_components, **extra_post_data):
175175
def make_request(self, path, extra_post_data=None, method="GET"):
176176
if self.delay:
177177
since_last = (datetime.datetime.utcnow() - self.last_request)
178-
since_last_in_seconds = (since_last.days * 24 * 60 * 60) + since_last.seconds + (since_last.microseconds/1000000.0)
179-
if since_last_in_seconds < self.delay:
180-
duration = self.delay - since_last_in_seconds
181-
LOGGER.warning("delaying API call %s second(s)", duration)
178+
if since_last.days == 0 and since_last.seconds < self.delay:
179+
duration = self.delay - since_last.seconds
180+
LOGGER.warning("delaying API call %g second(s)", duration)
182181
time.sleep(duration)
183182

184183
extra_post_data = extra_post_data or {}

0 commit comments

Comments
 (0)