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

AttributeError: 'MongoBackend' object has no attribute 'mongodb_options' #1303

Closed
ionelmc opened this issue Apr 12, 2013 · 4 comments
Closed

Comments

@ionelmc
Copy link
Contributor

ionelmc commented Apr 12, 2013

If set CELERY_MONGODB_BACKEND_SETTINGS to None or not set it at all you get this:

Traceback (most recent call last):
  File "bug.py", line 18, in <module>
    print [res.get(propagate=False) for res in results]
  File "/home/ionel/projects/celery-bug-1118/ve/local/lib/python2.7/site-packages/celery/result.py", line 108, in get
    interval=interval)
  File "/home/ionel/projects/celery-bug-1118/ve/local/lib/python2.7/site-packages/celery/backends/base.py", line 179, in wait_for
    status = self.get_status(task_id)
  File "/home/ionel/projects/celery-bug-1118/ve/local/lib/python2.7/site-packages/celery/backends/base.py", line 295, in get_status
    return self.get_task_meta(task_id)['status']
  File "/home/ionel/projects/celery-bug-1118/ve/local/lib/python2.7/site-packages/celery/backends/base.py", line 323, in get_task_meta
    meta = self._get_task_meta_for(task_id)
  File "/home/ionel/projects/celery-bug-1118/ve/local/lib/python2.7/site-packages/celery/backends/mongodb.py", line 133, in _get_task_meta_for
    obj = self.collection.find_one({'_id': task_id})
  File "/home/ionel/projects/celery-bug-1118/ve/local/lib/python2.7/site-packages/kombu/utils/__init__.py", line 294, in __get__
    value = obj.__dict__[self.__name__] = self.__get(obj)
  File "/home/ionel/projects/celery-bug-1118/ve/local/lib/python2.7/site-packages/celery/backends/mongodb.py", line 217, in collection
    collection = self.database[self.mongodb_taskmeta_collection]
  File "/home/ionel/projects/celery-bug-1118/ve/local/lib/python2.7/site-packages/kombu/utils/__init__.py", line 294, in __get__
    value = obj.__dict__[self.__name__] = self.__get(obj)
  File "/home/ionel/projects/celery-bug-1118/ve/local/lib/python2.7/site-packages/celery/backends/mongodb.py", line 212, in database
    return self._get_database()
  File "/home/ionel/projects/celery-bug-1118/ve/local/lib/python2.7/site-packages/celery/backends/mongodb.py", line 199, in _get_database
    conn = self._get_connection()
  File "/home/ionel/projects/celery-bug-1118/ve/local/lib/python2.7/site-packages/celery/backends/mongodb.py", line 107, in _get_connection
    *args, **dict(kwargs, self.mongodb_options)
AttributeError: 'MongoBackend' object has no attribute 'mongodb_options'

If you set it to a dict you get this:

Traceback (most recent call last):
  File "bug.py", line 18, in <module>
    print [res.get(propagate=False) for res in results]
  File "/home/ionel/projects/celery-bug-1118/ve/local/lib/python2.7/site-packages/celery/result.py", line 108, in get
    interval=interval)
  File "/home/ionel/projects/celery-bug-1118/ve/local/lib/python2.7/site-packages/celery/backends/base.py", line 179, in wait_for
    status = self.get_status(task_id)
  File "/home/ionel/projects/celery-bug-1118/ve/local/lib/python2.7/site-packages/celery/backends/base.py", line 295, in get_status
    return self.get_task_meta(task_id)['status']
  File "/home/ionel/projects/celery-bug-1118/ve/local/lib/python2.7/site-packages/celery/backends/base.py", line 323, in get_task_meta
    meta = self._get_task_meta_for(task_id)
  File "/home/ionel/projects/celery-bug-1118/ve/local/lib/python2.7/site-packages/celery/backends/mongodb.py", line 133, in _get_task_meta_for
    obj = self.collection.find_one({'_id': task_id})
  File "/home/ionel/projects/celery-bug-1118/ve/local/lib/python2.7/site-packages/kombu/utils/__init__.py", line 294, in __get__
    value = obj.__dict__[self.__name__] = self.__get(obj)
  File "/home/ionel/projects/celery-bug-1118/ve/local/lib/python2.7/site-packages/celery/backends/mongodb.py", line 217, in collection
    collection = self.database[self.mongodb_taskmeta_collection]
  File "/home/ionel/projects/celery-bug-1118/ve/local/lib/python2.7/site-packages/kombu/utils/__init__.py", line 294, in __get__
    value = obj.__dict__[self.__name__] = self.__get(obj)
  File "/home/ionel/projects/celery-bug-1118/ve/local/lib/python2.7/site-packages/celery/backends/mongodb.py", line 212, in database
    return self._get_database()
  File "/home/ionel/projects/celery-bug-1118/ve/local/lib/python2.7/site-packages/celery/backends/mongodb.py", line 199, in _get_database
    conn = self._get_connection()
  File "/home/ionel/projects/celery-bug-1118/ve/local/lib/python2.7/site-packages/celery/backends/mongodb.py", line 107, in _get_connection
    *args, **dict(kwargs, self.mongodb_options)
TypeError: dict expected at most 1 arguments, got 2
@ionelmc
Copy link
Contributor Author

ionelmc commented Apr 12, 2013

This happens on 3.0.18

ask added a commit that referenced this issue Apr 13, 2013
@razzmatazz
Copy link

Not sure if it is related, but I get another error with the following callstack:

[2013-04-15 17:22:40,960: CRITICAL/MainProcess] Task app.tasks.experimental.add[77b59c50-150b-4152-bb20-aae77ac64c4f] INTERNAL ERROR: TypeError('dict expected at most 1 arguments, got 2',)
Traceback (most recent call last):
  File "/Users/bob/src/comp/integration-cf/backend/venv/lib/python2.7/site-packages/celery/task/trace.py", line 263, in trace_task
    store_result(uuid, retval, SUCCESS)
  File "/Users/bob/src/comp/integration-cf/backend/venv/lib/python2.7/site-packages/celery/backends/base.py", line 282, in store_result
    self._store_result(task_id, result, status, traceback, **kwargs)
  File "/Users/bob/src/comp/integration-cf/backend/venv/lib/python2.7/site-packages/celery/backends/mongodb.py", line 126, in _store_result
    self.collection.save(meta, safe=True)
  File "/Users/bob/src/comp/integration-cf/backend/venv/lib/python2.7/site-packages/kombu/utils/__init__.py", line 294, in __get__
    value = obj.__dict__[self.__name__] = self.__get(obj)
  File "/Users/bob/src/comp/integration-cf/backend/venv/lib/python2.7/site-packages/celery/backends/mongodb.py", line 217, in collection
    collection = self.database[self.mongodb_taskmeta_collection]
  File "/Users/bob/src/comp/integration-cf/backend/venv/lib/python2.7/site-packages/kombu/utils/__init__.py", line 294, in __get__
    value = obj.__dict__[self.__name__] = self.__get(obj)
  File "/Users/bob/src/comp/integration-cf/backend/venv/lib/python2.7/site-packages/celery/backends/mongodb.py", line 212, in database
    return self._get_database()
  File "/Users/bob/src/comp/integration-cf/backend/venv/lib/python2.7/site-packages/celery/backends/mongodb.py", line 199, in _get_database
    conn = self._get_connection()
  File "/Users/bob/src/comp/integration-cf/backend/venv/lib/python2.7/site-packages/celery/backends/mongodb.py", line 107, in _get_connection
    *args, **dict(kwargs, self.mongodb_options)
TypeError: dict expected at most 1 arguments, got 2

I am using celery 3.0.18.

The code below looks a bit suspicious to me:

106             self._connection = Connection(
107                 *args, **dict(kwargs, self.mongodb_options)
108             )

I am not sure if you can construct a dict this way, even with || {}, as per http://docs.python.org/2/library/stdtypes.html. At the moment we are applying ourselves a patch that replaces dict(kwargs, self.mongodb_options) with dict(kwargs.items() + self.mongodb_options.items())

@ask ask closed this as completed in 4700183 Apr 15, 2013
@ask
Copy link
Contributor

ask commented Apr 15, 2013

Thanks, fixed.

dict(a, **b) is a common idiom, just forgot the stars that's all 🎱

ask added a commit that referenced this issue Apr 15, 2013
@ask
Copy link
Contributor

ask commented Apr 15, 2013

Also merged into 3.0 branch

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

No branches or pull requests

3 participants