mirror of
https://github.com/pretix/pretix.git
synced 2026-08-29 13:44:40 +00:00
More robust redis connections
This commit is contained in:
@@ -23,7 +23,11 @@ class AsyncAction:
|
|||||||
if not isinstance(self.task, app.Task):
|
if not isinstance(self.task, app.Task):
|
||||||
raise TypeError('Method has no task attached')
|
raise TypeError('Method has no task attached')
|
||||||
|
|
||||||
res = self.task.apply_async(args=args, kwargs=kwargs)
|
try:
|
||||||
|
res = self.task.apply_async(args=args, kwargs=kwargs)
|
||||||
|
except ConnectionError:
|
||||||
|
# Task very likely not yet sent, due to redis restarting etc. Let's try once agan
|
||||||
|
res = self.task.apply_async(args=args, kwargs=kwargs)
|
||||||
|
|
||||||
if 'ajax' in self.request.GET or 'ajax' in self.request.POST:
|
if 'ajax' in self.request.GET or 'ajax' in self.request.POST:
|
||||||
data = self._return_ajax_result(res)
|
data = self._return_ajax_result(res)
|
||||||
@@ -60,6 +64,14 @@ class AsyncAction:
|
|||||||
res.get(timeout=timeout, propagate=False)
|
res.get(timeout=timeout, propagate=False)
|
||||||
except celery.exceptions.TimeoutError:
|
except celery.exceptions.TimeoutError:
|
||||||
pass
|
pass
|
||||||
|
except ConnectionError:
|
||||||
|
# Redis probably just restarted, let's just report not ready and retry next time
|
||||||
|
data = self._ajax_response_data()
|
||||||
|
data.update({
|
||||||
|
'async_id': res.id,
|
||||||
|
'ready': False
|
||||||
|
})
|
||||||
|
return data
|
||||||
|
|
||||||
ready = res.ready()
|
ready = res.ready()
|
||||||
data = self._ajax_response_data()
|
data = self._ajax_response_data()
|
||||||
|
|||||||
Reference in New Issue
Block a user