vutran1710/PyrateLimiter

Issues with the schedule_leak method

Closed this issue · 2 comments

If the rates for a bucket change, the schedule_leak method does not update because of the use of a forever loop. This means that it can possibly leak valid items since it only considers the old rates. To fix this the sync version of the loop (def _leak_task_sync()) can have a flag instead of being while(True). Also, the sync version containing
thread = Thread(target=_leak_task_sync, daemon=True)
thread.start()
works with the addition of the flag as mentioned previously but will create an error when a large quantity of different buckets are created. You can run out of threads which will create an error. You could consider using a thread pool to limit the number of threads that can be used.

ill take a look when i got some free time

thread-usage fix in #145

Regarding the other issue with bucket's rate change, I will handle it with a separated issue