Document the BotSession reaper loop and why some of its race conditions are OK for this purpose.
- Improves/adds comments explaining why/how some of this works and why it's OK.
- Updates the
_update_next_expire_time
to not look at the shared OrderedDict when invoked through a_track_deadline_for_bot_session
— the new deadline is the only one that we need to compare with. - Only
.set()
the event if we do update the botsession as a small optimization. - Account for some rare race conditions that could make the
_evicted_bot_sessions
OrderedDict start growing >remember_last_n_evicted_bot_session
by removing not just one item, but as many items as needed to stay under that number when we clean-up. - Update
math.ceil
toround(num, 3)
and pad with only0.1s
to make sub-second or fractional timeouts a bit more "on-time". (useful for tests, real-world timeouts would probably be in the minutes range)
Edited by Marios Hadjimichael