Adam Hooper
Mar 24, 2021

--

There’s always another way :).

If you’re reading one message at a time, you can keep a “countdown” value. The pseudo-code:

  1. Set “deadline” to “now + 10s”
  2. Wait for the next message (passing “deadline minus now” as your library-specific timeout)
  3. Handle the message (decrementing your 500)
  4. If “deadline < now”, loop back to step 2

--

--