Pickle and unpickle a BaseUrlSession will result in an empty URL:
>>> from requests_toolbelt.sessions import BaseUrlSession
>>> import pickle
>>> session = BaseUrlSession(base_url="https://www.test.com")
>>> with open("pickled_session.pkl", "wb") as f:
... pickle.dump(session, f)
...
>>> with open("pickled_session.pkl", "rb") as f:
... s = pickle.load(f)
...
>>> s.base_url
>>> session.base_url
'https://www.test.com'
In requests, the attributes are handled the in:
def __getstate__(self):
state = {attr: getattr(self, attr, None) for attr in self.__attrs__}
return state
def __setstate__(self, state):
for attr, value in state.items():
setattr(self, attr, value)
I think base_url should also be handled in BaseUrlSession. I can create a PR for this and ask for you review
Pickle and unpickle a BaseUrlSession will result in an empty URL:
In
requests
, the attributes are handled the in:I think
base_url
should also be handled inBaseUrlSession
. I can create a PR for this and ask for you review