Skip to content

Commit dcbc7f1

Browse files
allow sync parameter to skip celery (#4018)
1 parent ba026c8 commit dcbc7f1

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

dojo/decorators.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,15 @@
1010
logger = logging.getLogger(__name__)
1111

1212

13-
def we_want_async():
13+
def we_want_async(*args, **kwargs):
1414
from dojo.utils import get_current_user
1515
from dojo.models import Dojo_User
1616

17+
sync = kwargs.get('sync', False)
18+
if sync:
19+
logger.debug('dojo_async_task: running task in the foreground as sync=True has been found as kwarg')
20+
return False
21+
1722
user = get_current_user()
1823

1924
if Dojo_User.wants_block_execution(user):
@@ -28,7 +33,7 @@ def we_want_async():
2833
def dojo_async_task(func):
2934
@wraps(func)
3035
def __wrapper__(*args, **kwargs):
31-
if we_want_async():
36+
if we_want_async(*args, **kwargs):
3237
return func.delay(*args, **kwargs)
3338
else:
3439
return func(*args, **kwargs)

0 commit comments

Comments
 (0)