Skip to content

Commit

Permalink
MongoDB: Pickle url with backend. Closes #2347
Browse files Browse the repository at this point in the history
Conflicts:
	celery/backends/mongodb.py
  • Loading branch information
ask committed Nov 18, 2014
1 parent 58fd480 commit ee1366a
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions celery/backends/mongodb.py
Expand Up @@ -56,15 +56,15 @@ class MongoBackend(BaseBackend):

_connection = None

def __init__(self, *args, **kwargs):
def __init__(self, app=None, url=None, **kwargs):
"""Initialize MongoDB backend instance.
:raises celery.exceptions.ImproperlyConfigured: if
module :mod:`pymongo` is not available.
"""
self.options = {}
super(MongoBackend, self).__init__(*args, **kwargs)
super(MongoBackend, self).__init__(app, **kwargs)
self.expires = kwargs.get('expires') or maybe_timedelta(
self.app.conf.CELERY_TASK_RESULT_EXPIRES)

Expand Down Expand Up @@ -95,10 +95,10 @@ def __init__(self, *args, **kwargs):
self.options.setdefault('max_pool_size', self.max_pool_size)
self.options.setdefault('auto_start_request', False)

url = kwargs.get('url')
if url:
self.url = url
if self.url:
# Specifying backend as an URL
self.host = url
self.host = self.url

def _get_connection(self):
"""Connect to the MongoDB server."""
Expand Down Expand Up @@ -210,9 +210,9 @@ def cleanup(self):
)

def __reduce__(self, args=(), kwargs={}):
kwargs.update(
dict(expires=self.expires))
return super(MongoBackend, self).__reduce__(args, kwargs)
return super(MongoBackend, self).__reduce__(
args, dict(kwargs, expires=self.expires, url=self.url),
)

def _get_database(self):
conn = self._get_connection()
Expand Down

0 comments on commit ee1366a

Please sign in to comment.