How does the Python SDK handle token refresh during a long-running batch job?

How exactly does the Python SDK swap out an expired access token when we’re processing a large queue analytics export? We’ve got a script that pulls routing config and UI layout states for about two thousand agents, but it consistently bombs out halfway through. The initial auth works fine, but the refresh endpoint just stops responding once the batch hits the fifty-minute mark.

Problem

The job loops through /api/v2/routing/queues and /api/v2/admin-ui/layouts, saving the JSON to S3. Around iteration 140, the SDK throws an unhandled exception instead of automatically fetching a new token. We’ve tried setting token_refresh_callback, but the closure never fires.

client = genesyscloud.platform_client.PlatformClient(
 oauth_client_id=OAUTH_ID,
 oauth_client_secret=OAUTH_SECRET,
 oauth_token_url=TOKEN_URL
)
response = client.routing.get_routing_queue(queue_id=q_id)

Error

genesyscloud.platform_client.exceptions.ApiException: (401) Unauthorized. Reason: Access token expired.

Question

Should we manually trigger client.oauth_client.refresh_token() inside a try-except block, or is there a built-in retry mechanism we’re missing? The docs mention automatic rotation, yet the request pipeline just drops the connection. We’re running this from a Pacific-time EC2 instance during off-hours, so network latency isn’t the issue. The callback gets a 200 back from the auth server. Next request still uses the old bearer string. Makes zero sense.