Skip to content

Conversation

@stabbedbybrick
Copy link

Since curl_cffi doesn't support retry functionality, I've added some properties to the CurlSession that somewhat mimic the Retry handler from urllib3. It also allows you to set custom values that'll override the default ones.

Example:

from unshackle.core.session import session as CurlSession

class MyService(Service):
     @staticmethod
     def get_session() -> CurlSession:
         session = CurlSession(
             impersonate="chrome",
             ja3="...",
             akamai="...",
             max_retries=5,
             status_forcelist=[429, 500],
             allowed_methods={"GET", "HEAD", "OPTIONS"},
         )
         return session  # Uses config default browser

Note: It requires an update to the latest stable version of curl_cffi (v0.13.0). I've tested a few scenarios and the update doesn't seem to break anything, but might be worth an extra look just to make sure.

@Sp5rky
Copy link
Contributor

Sp5rky commented Oct 20, 2025

Thanks for the PR! The retry handler implementation looks solid. I've modernized the type annotations to use Python 3.10+ PEP 604 syntax (list[int] | None instead of Optional[List[int]]) since the project requires Python 3.10+.

Commit: 5384b77

I'll continue to test this over next few days as I have a few services that use curl_cffi so will be good to test how it handles, but so far it handled the retry perfectly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants