Explain recent update Frappe Version 13.19.0 : frappe.call in server script

Can anyone help me to understand how to use this new feature in latest release of version 13.19.0

  • Added frappe.enqueue and frappe.call for server scripts (#15528).

Specially how to use frappe.call along with parameters

@zulfi007 frappe.call will just call a method and run it instantly . frappe.enqueue will also call a method and put it in a waiting queue to be executed .

Can you share example along with arguments.

@zulfi007 frappe.call(“frappe.example.example”). I tested it without arguments and it works . with arguments it did not work . I will do some more test and come back to you.
also the feature was erased from the v13.19 releases . it may not be working properly.

@bahaou Thanks for testing and sharing

I tested it as below and it worked.

  1. In a custom app I had that is named listup I created a python file called triggers.py I put it in the same directory as hooks.py. See the directory structure below:

  2. Then in the server script I added the below code:

  3. In triggers.py I had a function called worked that write data to log. See below:

    import frappe
    logger = frappe.logger(“queue”, allow_site=True, file_count=50)

    def worked():
    logger.info(f"frappe.call worked.")

It worked as expected.

I think the newly released function in Frappe source code is this. Am not sure though.

Thanks. What about argument passing

An argument can be passed as 2nd parameter.

For example:
frappe.call('listup.triggers.worked', arg1=doc)