Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Fix negative delays in sqlite middleware #49

Merged
merged 1 commit into from
Sep 19, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions epo_ops/middlewares/throttle/storages/sqlite.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,13 @@ def delay_for(self, service):
)
else:
next_run = _now + timedelta(seconds=60.0 / r[limit])
td = next_run - _now
ts = td.microseconds + (td.seconds + td.days * 24 * 3600) * 10 ** 6
return ts / 10 ** 6

if next_run < _now:
return 0.0
else:
td = next_run - _now
ts = td.microseconds + (td.seconds + td.days * 24 * 3600) * 10 ** 6
return ts / 10 ** 6

def update(self, headers):
"This method is a public interface for a throttle storage class"
Expand Down