How to check if background jobs is done

Hello im new to frappe/erpnext is it possible to check the status of background jobs ? I use this method to create a background job enqueue(method, queue='default', timeout=None, event=None, is_async=True, job_name=None, now=False, enqueue_after_commit=False, **kwargs)

I want to get the background status so that i can disable or enable the button in frappe disable if the background is still running

1 Like

I used a work around for this. Add a status fields and upon button click, the status is set to activate.

And when the background job is completed, it’s last step was to set the status as inactive.

And the button click had an if condition to check the value of status before proceeding to create the background check.

1 Like

@rtdany10 Nice idea,
Could you share the code so All of us get the benefit from this :slightly_smiling_face:

Here you go.
Function executed on button click:

def func():
	doc = frappe.get_doc(doctype, docname)
	if doc.status == 'Active':
		frappe.msgprint('Background job already running.')
	frappe.msgprint('Backgroud Job Created.')
	doc.status = 'Active'
    frappe.enqueue('', queue='long')

And the background job:

    # do your thing and then
	doc = frappe.get_doc(doctype, docname)
	doc.status = 'Inactive'