You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Mention pickling in the docs for creating custom Transport Adapters #6255
While subclassing HTTPAdapter as well as Session the class variable __attrs__ needs to be appended with any custom instance variables. Otherwise, the instance breaks during pickling, which can happen in many different scenarios - for example, during Django's setUpTestData deep copying/in-memory data isolation. I think it would be nice if this is mentioned in the documentation.
There's a classic example of a custom adapter for setting a timeout value that is mentioned in multiple blog posts. Unfortunately, all of these examples are essentially broken because of a lack of information about pickling and __attrs__ class variable.
And yet the pattern of overriding __attrs__ exists in many open source libs, for example:
If this pattern is so commonly used and needed, it might be a good idea to add it to the docs. Again, this is because so many people can stumble upon this issue.
Activity