Hitting 429 on bulk user updates, need backoff logic

Running a script to update routing skills for ~500 users via the Genesys Cloud API. Hitting PUT /api/v2/users/{userId} in a loop.

The rate limit headers look like this:

X-RateLimit-Limit: 100
X-RateLimit-Remaining: 0
Retry-After: 10

Current Python snippet:

response = session.put(url, json=payload)
if response.status_code == 429:
 wait_time = int(response.headers.get('Retry-After', 5))
 time.sleep(wait_time)
 response = session.put(url, json=payload)

It works for a bit then crashes with ConnectionError or just hangs. The Retry-After header isn’t always consistent. Sometimes it’s missing.

What’s the standard way to handle exponential backoff here without blocking the whole thread? Should I be checking the X-RateLimit-Reset header instead?

Also, is there a bulk endpoint I’m missing for user updates? The docs only show single user PUTs.

Using requests library v2.31.0. Python 3.10.