See Ash Code logo See Ash Code

A program that is waiting should tell me what it is waiting for

Ashlynn Antrobus
• • 2 min read

My Markdown ingester could spend a long time waiting for an API allowance to recover. It logged the wait once, then went quiet.

That left a fairly basic question unanswered: was it still waiting, or had it stopped doing anything?

An example progress bar filled to about one fifth.

An illustrative progress bar by Emil Larsen, released into the public domain. The ingester reported remaining time as log messages rather than a bar.

The limiter from the previous post needs to pause when its recorded usage reaches a configured limit. Removing that pause would defeat the limiter. I needed to make the pause understandable.

Say why the program stopped sending work

The initial rate-limit message includes the calculated wait, the minute and daily request totals, and the token total. Those details explain why another request hasn’t gone out yet.

But the message can scroll away. If I look at the terminal much later, a lone old log entry doesn’t tell me whether the process is still making its way through the wait.

The progress-logging change, merged with the November 28 work, breaks the sleep into intervals and logs the remaining delay between them.

Choosing how often to speak

The interval calculation is:

return min(max(60.0, wait_time / 2.0), 1800.0)

It starts with half the wait and clamps that interval between one minute and thirty minutes. Short waits don’t need constant updates. Longer waits get occasional signs that the process is still in the cooldown path.

The sleep helper subtracts each completed interval, then reports:

logger.info(f"Still waiting... {remaining:.2f}s remaining")

For a hypothetical five-minute delay, the interval is 150 seconds. The intermediate message would be:

Still waiting... 150.00s remaining

That is an illustration calculated from the code, not a recording of an actual ingestion run. After the remaining delay, the limiter can check the request again.

What the heartbeat establishes

The message tells me the process reached another point in its waiting loop. The remaining time comes from the delay and completed sleeps, not a fresh provider quota measurement. It doesn’t mean the next request has been accepted or ingestion has finished.

I can leave an ingestion running and see when the limiter expects to resume, without a log line for every second of the wait.

AA

Written by Ashlynn Antrobus

Software developer, author, and builder. Sharing technical lessons learned from building tools like Ebook2Text, IndexedDict, and rag-mcp, and navigating life as a programmer with dyslexia.