Merge pull request #16256 from ankush/is_async_commit

fix!: run synchronous background jobs directly in production
This commit is contained in:
Ankush Menat 2022-03-14 15:57:17 +05:30 committed by GitHub
commit b16c8efa30
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -57,7 +57,11 @@ def enqueue(method, queue='default', timeout=None, event=None,
# To handle older implementations
is_async = kwargs.pop('async', is_async)
if now or frappe.flags.in_migrate:
if not is_async and not frappe.flags.in_test:
print(_("Using enqueue with is_async=False outside of tests is not recommended, use now=True instead."))
call_directly = now or frappe.flags.in_migrate or (not is_async and not frappe.flags.in_test)
if call_directly:
return frappe.call(method, **kwargs)
q = get_queue(queue, is_async=is_async)