Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Cannot pickle _thread.RLock object when saving cookieJar #389

Closed
MrMarble opened this issue Sep 21, 2024 · 1 comment
Closed

[BUG] Cannot pickle _thread.RLock object when saving cookieJar #389

MrMarble opened this issue Sep 21, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@MrMarble
Copy link

MrMarble commented Sep 21, 2024

Describe the bug
I copied the example in https://curl-cffi.readthedocs.io/en/latest/cookies.html#how-to-save-and-load-cookies and when trying to call save_cookies(client) I get this error.

To Reproduce

from curl_cffi import requests
import pickle

def save_cookies(client):
    with open("cookies.pk", "wb") as f:
        pickle.dump(client.cookies.jar, f)


def main():
    client = requests.Session(impersonate="chrome")
    client.get("https://httpbin.org/cookies/set/foo/bar")
    save_cookies(client)

if __name__ == "__main__":
    main()

Expected behavior
Pickle is able to save the cookieJar to a file

Versions

  • OS: Windows 11
  • Python: 3.10.6
  • curl_cffi version 0.7.1
beautifulsoup4==4.12.3
certifi==2024.8.30
cffi==1.17.1
charset-normalizer==3.3.2
curl_cffi==0.7.1
idna==3.10
pyaml==24.7.0
pycparser==2.22
PyYAML==6.0.2
soupsieve==2.6
urllib3==2.2.3

Additional context

  • I was able to save the cookies using normal requests session (before switching to curl_cffi)
@MrMarble MrMarble added the bug Something isn't working label Sep 21, 2024
@lexiforest
Copy link
Owner

Sorry, this is a misleading example that actually does not work. We have discussed this in #43 and I will update the docs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants