mirror of
https://github.com/python/cpython.git
synced 2025-12-04 00:30:19 +00:00
gh-116622: Mock the passage of time in Android logcat rate limit tests (#124015)
Mock the passage of time in Android logcat rate limit tests Co-authored-by: Russell Keith-Magee <russell@keith-magee.com>
This commit is contained in:
parent
584cdf8d41
commit
f554883425
2 changed files with 30 additions and 7 deletions
|
|
@ -165,7 +165,10 @@ class Logcat:
|
|||
now = time()
|
||||
self._bucket_level += (
|
||||
(now - self._prev_write_time) * MAX_BYTES_PER_SECOND)
|
||||
self._bucket_level = min(self._bucket_level, BUCKET_SIZE)
|
||||
|
||||
# If the bucket level is still below zero, the clock must have gone
|
||||
# backwards, so reset it to zero and continue.
|
||||
self._bucket_level = max(0, min(self._bucket_level, BUCKET_SIZE))
|
||||
self._prev_write_time = now
|
||||
|
||||
self._bucket_level -= PER_MESSAGE_OVERHEAD + len(tag) + len(message)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue