Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 6 additions & 10 deletions tap_github/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
from __future__ import annotations

import email.utils
import inspect
import random
import time
from typing import TYPE_CHECKING, Any, ClassVar, cast
Expand All @@ -19,7 +18,6 @@

if TYPE_CHECKING:
from collections.abc import Iterable
from types import FrameType

import requests
from backoff.types import Details
Expand Down Expand Up @@ -330,15 +328,13 @@ def post_process(self, row: dict, context: Context | None = None) -> dict:
def backoff_handler(self, details: Details) -> None:
"""Handle retriable error by swapping auth token."""
self.logger.info("Retrying request with different token")
# use python introspection to obtain the error object
# FIXME: replace this once https://github.com/litl/backoff/issues/158
# is fixed
exc = cast(
"FrameType",
cast("FrameType", cast("FrameType", inspect.currentframe()).f_back).f_back,
).f_locals["e"]
# backoff now passes the exception directly in `details`, so we no
# longer need to rely on frame introspection to retrieve it.
# See https://github.com/litl/backoff/issues/158.
exc = details.get("exception")
if (
exc.response is not None
isinstance(exc, RetriableAPIError)
and exc.response is not None
and exc.response.status_code == 403
and "rate limit exceeded" in str(exc.response.content)
):
Expand Down
Loading