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

MaxRetryError is not pickleable (has failing test, needs fix) #101

Merged
merged 5 commits into from Sep 13, 2012

Conversation

shazow
Copy link
Member

@shazow shazow commented Sep 13, 2012

Progress branch for #100.

Related bug report: celery/billiard#18

@shazow
Copy link
Member Author

shazow commented Sep 13, 2012

Current failure:

ERROR: test_exceptions_with_objects (test.test_exceptions.TestPickle)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/shazow/projects/urllib3/test/test_exceptions.py", line 18, in test_exceptions_with_objects
    assert pickle.dumps(MaxRetryError(HTTPConnectionPool('localhost'), '/'))
  File "/usr/lib/python2.7/pickle.py", line 1374, in dumps
    Pickler(file, protocol).dump(obj)
  File "/usr/lib/python2.7/pickle.py", line 224, in dump
    self.save(obj)
  File "/usr/lib/python2.7/pickle.py", line 331, in save
    self.save_reduce(obj=obj, *rv)
  File "/usr/lib/python2.7/pickle.py", line 419, in save_reduce
    save(state)
  File "/usr/lib/python2.7/pickle.py", line 286, in save
    f(self, obj) # Call unbound method with explicit self
  File "/usr/lib/python2.7/pickle.py", line 649, in save_dict
    self._batch_setitems(obj.iteritems())
  File "/usr/lib/python2.7/pickle.py", line 663, in _batch_setitems
    save(v)
  File "/usr/lib/python2.7/pickle.py", line 331, in save
    self.save_reduce(obj=obj, *rv)
  File "/usr/lib/python2.7/pickle.py", line 419, in save_reduce
    save(state)
  File "/usr/lib/python2.7/pickle.py", line 286, in save
    f(self, obj) # Call unbound method with explicit self
  File "/usr/lib/python2.7/pickle.py", line 649, in save_dict
    self._batch_setitems(obj.iteritems())
  File "/usr/lib/python2.7/pickle.py", line 663, in _batch_setitems
    save(v)
  File "/usr/lib/python2.7/pickle.py", line 286, in save
    f(self, obj) # Call unbound method with explicit self
  File "/usr/lib/python2.7/pickle.py", line 725, in save_inst
    save(stuff)
  File "/usr/lib/python2.7/pickle.py", line 286, in save
    f(self, obj) # Call unbound method with explicit self
  File "/usr/lib/python2.7/pickle.py", line 649, in save_dict
    self._batch_setitems(obj.iteritems())
  File "/usr/lib/python2.7/pickle.py", line 663, in _batch_setitems
    save(v)
  File "/usr/lib/python2.7/pickle.py", line 331, in save
    self.save_reduce(obj=obj, *rv)
  File "/usr/lib/python2.7/pickle.py", line 419, in save_reduce
    save(state)
  File "/usr/lib/python2.7/pickle.py", line 286, in save
    f(self, obj) # Call unbound method with explicit self
  File "/usr/lib/python2.7/pickle.py", line 649, in save_dict
    self._batch_setitems(obj.iteritems())
  File "/usr/lib/python2.7/pickle.py", line 663, in _batch_setitems
    save(v)
  File "/usr/lib/python2.7/pickle.py", line 306, in save
    rv = reduce(self.proto)
  File "/home/shazow/env/urllib3/lib64/python2.7/copy_reg.py", line 70, in _reduce_ex
    raise TypeError, "can't pickle %s objects" % base.__name__
TypeError: can't pickle lock objects

@shazow
Copy link
Member Author

shazow commented Sep 13, 2012

@kennethreitz @ask Fixed the __init__ thing (looks like pickle doesn't like super() either, goes into infinite recursion) but MaxRetryError still won't pickle as long as it holds a reference to the pool which contains a lock object.

Suggestions?

@ask
Copy link

ask commented Sep 13, 2012

@shazow: Does it really need the pool when it restores the object on the other side?

If not you could add:

def __reduce__(self):
    return self.__class__, (None, self.url)

@shazow
Copy link
Member Author

shazow commented Sep 13, 2012

That sounds good. If this use case becomes more popular then maybe it'll be worthwhile having a neutered version of a PickledConnectionPool or something.

shazow added a commit that referenced this pull request Sep 13, 2012
@shazow shazow merged commit 7f48f6b into master Sep 13, 2012
@shazow
Copy link
Member Author

shazow commented Sep 13, 2012

@kennethreitz Ready to go, feel free to pull master upstream.

@ask Thank you for your help!

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.

None yet

2 participants