From 3add8e8a390dd09ba832e28c20790cf3cb996209 Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Thu, 2 Feb 2017 11:24:36 +0530 Subject: [PATCH] [minor] pass now in enqueue --- frappe/__init__.py | 2 +- frappe/utils/background_jobs.py | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/frappe/__init__.py b/frappe/__init__.py index b8a523e49f..a2c16284a4 100644 --- a/frappe/__init__.py +++ b/frappe/__init__.py @@ -1286,7 +1286,7 @@ def enqueue(*args, **kwargs): :param kwargs: keyword arguments to be passed to the method ''' import frappe.utils.background_jobs - frappe.utils.background_jobs.enqueue(*args, **kwargs) + return frappe.utils.background_jobs.enqueue(*args, **kwargs) def get_doctype_app(doctype): def _get_doctype_app(): diff --git a/frappe/utils/background_jobs.py b/frappe/utils/background_jobs.py index 4a98bb767c..b97f4c5069 100755 --- a/frappe/utils/background_jobs.py +++ b/frappe/utils/background_jobs.py @@ -15,7 +15,7 @@ queue_timeout = { } def enqueue(method, queue='default', timeout=300, event=None, - async=True, job_name=None, **kwargs): + async=True, job_name=None, now=False, **kwargs): ''' Enqueue method to be executed using a background worker @@ -27,6 +27,9 @@ def enqueue(method, queue='default', timeout=300, event=None, :param job_name: can be used to name an enqueue call, which can be used to prevent duplicate calls :param kwargs: keyword arguments to be passed to the method ''' + if now: + return frappe.call(method, **kwargs) + q = get_queue(queue, async=async) if not timeout: timeout = queue_timeout.get(queue) or 300