Django-facebook icon indicating copy to clipboard operation
Django-facebook copied to clipboard

Getting AttributeError: 'OpenFacebook' object has no attribute 'version' error when i use django_facebook.tasks.get_and_store_likes

Open julianfox opened this issue 9 years ago • 2 comments

Hello,

When i try to use django_facebook.tasks.get_and_store_likes with Celery i have this error :

[2014-11-16 12:51:23,700: ERROR/MainProcess] Task django_facebook.tasks.get_and_store_likes[3b388b18-18f7-4243-9985-58354760d794] raised unexpected: AttributeError("'OpenFacebook' object has no attribute 'version'",)
Traceback (most recent call last):
  File "/Users/julian/Dev/hv/venv/lib/python2.7/site-packages/celery/app/trace.py", line 240, in trace_task
    R = retval = fun(*args, **kwargs)
  File "/Users/julian/Dev/hv/venv/lib/python2.7/site-packages/celery/app/trace.py", line 437, in __protected_call__
    return self.run(*args, **kwargs)
  File "/Users/julian/Dev/hv/venv/lib/python2.7/site-packages/django_facebook/tasks.py", line 76, in get_and_store_likes
    stored_likes = facebook._get_and_store_likes(user)
  File "/Users/julian/Dev/hv/venv/lib/python2.7/site-packages/django_facebook/api.py", line 522, in _get_and_store_likes
    likes = self.get_likes()
  File "/Users/julian/Dev/hv/venv/lib/python2.7/site-packages/django_facebook/api.py", line 530, in get_likes
    likes_response = self.open_facebook.get('me/likes', limit=limit)
  File "/Users/julian/Dev/hv/venv/lib/python2.7/site-packages/open_facebook/api.py", line 725, in get

AttributeError: 'OpenFacebook' object has no attribute 'version'

And "get_and_store_likes" function work well if i set False FACEBOOK_CELERY_STORE

How do I fix this error?

julianfox avatar Nov 16 '14 12:11 julianfox

Hi Julian,

I'm getting this same error. I've traced it down through the code and determined that when FacebookUserConverter calls get_and_store_likes.delay(user, self), self.open_facebook has the version properly set to 'v1.0'. After calling this on the queue, facebook.open_facebook no longer has an attribute for the version. I'm assuming that what's going on is that the object is being pickled over the wire, and the version attribute is not being retained in the process. I'm looking into a few ways to fix this, but have not found anything suitable yet. I'm not sure if it's also caused by the celery backend that I'm using, but I'm using RabbitMQ if that's helpful to anyone.

I'll let you know if I find a suitable fix. Hoping some others chime in here since I'm actually 1 day new to the project.

-Jason

jskitz avatar Dec 25 '14 00:12 jskitz

Hello jskitz, yes i fixed it, right now i am on a another project... i'll try to retrieve my code tomorrow for write the solution here ;-)

julianfox avatar Dec 26 '14 13:12 julianfox