How to create the Background Jobs using frappe.enqueue function


I am trying to use the background jobs and using frappe.enqueue function by hooks. It is creating the workers but not jobs. Anyone please help me.

Here is the code,

import frappe
import string
from frappe.utils.background_jobs import enqueue

def daily():

def test_enqueue_function():
print(“\n\n\n enqueue \n\n\n”)

if you pass a string here then make sure it’s dot path to function. e.g. app_name.queue.test_enqueue_function

if you wish to pass it as function directly then don’t use string. import and pass the function itself.

enqueue(method=frappe.method_name, queue=‘short’, timeout=300, is_async=True, **args)

@qrevel ,

I changed the function to dotted path like this

frappe.enqueue(‘gym_management.gym_management.doctype.gym_member.gym_member.long_running_job’, queue=‘short’, now=True, is_async=True, timeout=300, param1=‘A’, param2=‘B’)

Even after that also, getting the error like below

Error message suggests there is error in module path.

Try importing and passing the function instead of using dot path string.