Background jobs - Frappe training session
Here is the code we have mentioned in the training video. https://youtu.be/LSKhjYwBAHw
·
1 min read
Here is the code we have mentioned in the training video. https://youtu.be/LSKhjYwBAHw
importdef before_save(self):frappe.enqueue(self.time_taking_process,queue="short",timeout=200,is_async=True)
def time_taking_process(self):# frappe.publish_realtime('msgprint', 'Starting long job...')frappe.publish_progress(25, title='Some title', description='Some description')time.sleep(10)frappe.publish_progress(50, title='Some title', description='Some description')time.sleep(20)frappe.publish_progress(75, title='Some title', description='Some description')time.sleep(30)frappe.publish_progress(100, title='Some title', description='Some description')# frappe.enqueue(# data = math.factorial(1000000),# frappe.log("done factorial: " ,"done factorial")frappe.log_error(title='done factorial', message="done factorial")frappe.publish_progress(25, title='Some title', description='Some description')# frappe.publish_realtime('msgprint', 'ended long job...', alert=True)# frappe.msgprint(# "finished factorial calculation",# alert=True,# )# frappe.msgprint( "finished factorial calculation frappe.msgprint")
response = requests.post(document_url, data=payload, headers=headers)memory_url=self.create_pdf(doc)
current_time =now()frappe.get_doc({"doctype":"bg-succes log","title":"Successfully created background job","message":"Success log","time":current_time }).insert()
frappe.enqueue('myapp.mymodule.long_job', arg1=arg1, arg2=arg2)
Tech Reporter
Our team reports from all over the Gulf. Contact us on news@ERPGulf.com
20 comments
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1