-
-
Notifications
You must be signed in to change notification settings - Fork 866
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
Not able to use JIRA authed instance as pickle serialized object. #259
Comments
I will close this because I don't see it as a bug in |
It does not work work even when I try to send jira instance to a multiprocessing apply_async method. |
Hi, my workaround was simple though,
Obviously you will might need to change it up a bit depending to match your naming schemes. |
I had exactly this problem as well. The above workaround was only a partial fix for me. I also had to setattr for timeout. Perhaps it is related to setting optional values? |
I have also problems with this Exception. In order to run my scripts using multiple threads I have to apply: diff --git a/resilientsession.py b/resilientsession.py
index 334981f..d18bdf9 100644
--- a/resilientsession.py
+++ b/resilientsession.py
@@ -117,15 +117,11 @@ class ResilientSession(Session):
data = json.dumps(data)
retry_number = 0
+ if not hasattr(self, 'max_retries'):
+ self.max_retries = 3
while retry_number <= self.max_retries:
response = None
exception = None
try:
method = getattr(super(ResilientSession, self), verb.lower())
+ if not hasattr(self, 'timeout'):
+ self.timeout = None
response = method(url, timeout=self.timeout, **kwargs)
if response.status_code == 200:
return response
Such a demonstration would at least help avoiding this problem. |
I have got the same issue. Thanks pktiuk for your fix. this issue should be reopened !!!! |
I also think so, in my company many people have this problem and all of us have to apply this fix on official libraries. |
Looks like the issue still present in the version 3.2.0, is anything that could be done to get the solution proposed by @pktiuk implemented? |
bump |
ResilientSession extends Session which in turn implements the getstate and setstate interface. When pickle starts serializing ResilientSession it notices the class has the getstate interface and uses that instead The Session uses an internal attribute name list 'attrb' to store the states that should be persisted/serialized. We could extend the list to encompass the attributes from ResilientSession. This is what we are using: diff --git a/jira/resilientsession.py b/jira/resilientsession.py
index f5447f2..f75dc71 100644
--- a/jira/resilientsession.py
+++ b/jira/resilientsession.py
@@ -160,6 +160,7 @@ class ResilientSession(Session):
self.timeout = timeout
self.max_retries = max_retries
self.max_retry_delay = max_retry_delay
+ self.__attrs__.extend(["timeout","max_retries","max_retry_delay"])
super().__init__()
# Indicate our preference for JSON to avoid https://bitbucket.org/bspeakmon/jira-python/issue/46 and https://jira.atlassian.com/browse/JRA-38551
Regards, |
I am trying to save a jira authed instance as a pickle serialized object in a Django's request session.
The object is saved successfully and pickled, unpickled succesfully.
However when using the stored instance, it gives error:
The text was updated successfully, but these errors were encountered: