mirror of
https://github.com/GSA/notifications-api.git
synced 2026-01-30 14:31:57 -05:00
Simplify argument passing in apply_async
This avoids the need to keep in-sync with any future changes to the signature, and reduces the amount of irrelevant code to read.
This commit is contained in:
@@ -73,16 +73,15 @@ def make_task(app, statsd_client):
|
||||
|
||||
return super().__call__(*args, **kwargs)
|
||||
|
||||
def apply_async(self, args=None, kwargs=None, task_id=None, producer=None,
|
||||
link=None, link_error=None, **options):
|
||||
kwargs = kwargs or {}
|
||||
def apply_async(self, *args, **kwargs):
|
||||
kwargs['kwargs'] = kwargs.get('kwargs', {})
|
||||
|
||||
if has_request_context() and hasattr(request, 'request_id'):
|
||||
kwargs['request_id'] = request.request_id
|
||||
kwargs['kwargs']['request_id'] = request.request_id
|
||||
elif has_app_context() and 'request_id' in g:
|
||||
kwargs['request_id'] = g.request_id
|
||||
kwargs['kwargs']['request_id'] = g.request_id
|
||||
|
||||
return super().apply_async(args, kwargs, task_id, producer, link, link_error, **options)
|
||||
return super().apply_async(*args, **kwargs)
|
||||
|
||||
return NotifyTask
|
||||
|
||||
|
||||
Reference in New Issue
Block a user