Alert during background job

Hello Everyone.

I have a long-running task that I have queued using the enqueue function.

Now, I want to send updates to the UI while the job is running in the background so as to notify the user what task is being executed.

I have tried using frappe.msgprint(message,alert=True) but it only reflects before the job starts and never during execution.

Since the job is running in the background I can’t use frappe.set_alert in js.

Does anyone have any idea what approach can be used?

@Ebuka_Joseph_Akeru, you can send websocket messages!

The bench manager does exactly this, while running message commands!

In the backend:

The command is enqueued here

The websocket message from the command is generated here

On the UI it’s listen here:

But the console on the UI is initiated here

Keep in mind, the key it’s used as an topic, for you be able to watch these messages on the frontend!


@max_morais_dmm Thanks a lot for your help, it seems I will have to set up a listener in js for this to work, I will give it. a try and keep you updated, Many thanks again.