6👍
✅
You can always fire off a thread:
import threading
class PreserializeThread(threading.Thread):
def __init__(self, mquery_pk, company_uuid, *args, **kwargs):
self.mquery_pk = mquery_pk
self.company_uuid = company_uuid
super(PreserializeThread, self).__init__(*args, **kwargs)
def run(self):
preserialize(self.mquery_pk, self.company_uuid)
Then, replace preserialize
in your code sample with:
PreserializeThread(mquery.pk, company_uuid).start()
1👍
Simple answer, no.
Your function will take until serialization is finished before continuing execution.
Have a look at django-celery for a task queuing solution.
As of 2020, celery now supports Django out of the box.
- [Django]-Why does <myproject>/accounts/profile/ show the <myproject>/profile/ page
- [Django]-How do i split a very long string into a list of shorter strings in python
Source:stackexchange.com