I have added a function into Frappe Queue using frappe.enqueue
import method from another_file
frappe.enqueue(
method,
queue='default',
job_name="Make a API Call to External Server,
data_obj=data_obj,
)
Now in the another_file from where the method is being called, I am taking the URL and Authentication data from site_config.json like
SERVER_URL = frappe.local.conf.url
def call_api(data_obj, resource_id):
response = requests.put(SERVER_URL, data=json.dumps(data_obj))
This simply does not work, So after a bit of digging I found this in the worker.error.logs
File "/workspace/development/frappe-bench/apps/mainapp/mainapp/APIHandler/APIHandler.py", line 7, in <module>
SERVER_URL = frappe.local.conf.url
File "/workspace/development/frappe-bench/env/lib/python3.10/site-packages/werkzeug/local.py", line 88, in __getattr__
raise AttributeError(name)
AttributeError: conf
Without using the queue or hard coding the URL value in the code works, but both are not acceptable practices.
How to mitigate this issue, any workarounds ?
Thanks in Advance