A whitelisted function that uses enqueue(aMethod) responds only when queued job ends

I need to launch a long running process through an API call.

I have this:

from frappe.utils.background_jobs import enqueue
     :     :     :     :
@frappe.whitelist()
def test_enqueue():
   ulog("Enqueuing Long Task")
   enqueue('myapp.myapp.doctype.myapp.myapp.longTask', now = True, timeout=120000)
   return { "result": "Enqueued Long Task" }

I expected to get the immediate response, {"message":{"result":"Enqueued Long Task"}}.
Instead, I get that response message only when the “enqueued” process completes (after about 10 minutes).

Have I misunderstood something?


Notes:

  1. Version: ERPNext V13.beta.6
  2. in ${benchDir}/config/supervisor.conf
     :     :     :     :
[program:frappe-bench-DENH-frappe-web]
command=/home/erpdev/frappe-bench-DENH/env/bin/gunicorn -b 127.0.0.1:8000 -w 4 -t 120 frappe.app:application --preload
priority=4
     :     :     :     :

Try to remove now = True
And you can use something like this
enqueue(method=make_payment_entry, queue='short', timeout=1000, is_async=True , kwargs =nmb_doc )

2 Likes

That did the trick.

Waaaaay too easy to assume async would be the default, no?