First step in refactoring backoff
First step in refactoring backoff

If a 429 is received, check for a backoff duration header and sleep
that long.

This is all totally wrong, because it sleeps AFTER a request has
returned, but before any other processing takes place. The flow should
be as follows:

After request returns:
If backoff header is found:
    store current time as Zot.backoff_start, Zot.backoff = True,
    Zot.delay_duration += delay
    start countdown timer, on completion set Zot.backoff = false,
    Zot.delay_duration = 0

Before Request is made:
check if Zot.backoff=True
if yes:
    if (Zot.backoff_start + Zot.delay_duration) - current_time >
    delay_duration, we're OK
    otherwise, sleep for (Zot.backoff_start + Zot.delay_duration) -
    current_time before making request

urschrei/pyzotero