Skip to content

Document the BotSession reaper loop and why some of its race conditions are OK for this purpose.

Marios Hadjimichael requested to merge marios/document-reaper-loop into master
  • 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 to round(num, 3) and pad with only 0.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

Merge request reports