How can I implement threading or async process in erpnext?

How can I implement threading or async process in erpnext?

What is the use case?

I need to sync data in the background,for that I am calling a RESTful api once a day. But It is giving me time out error “504” as data is very large. So is there any way to implement threading or async functionality?

You could make use of frappe.utils.background_jobs. ERPNext has in-built Dropbox integration. Browsing the code for that might help.