I have Django view:
def func():
...
instance = ...create()
func2(instance)
instance.attr = attr
etc...
So func() creates an instance, calls func2() and keeps on working.
def func2(instance):
request = request(instance)
wait response
response.data.save()
The result of function 1 and function 2 are in no way related. Function 2 is related to output/input operations. Function 2 must be called by function 1 and must not block the operation of function 1. In the current project version, func2 is called with celery. But I’m not sure that’s the right way, and it’s better to call func2 with another thread.
def func():
...
instance = ...create()
thread = threading.Thread(target=func2, args=instance)
thread.run()
instance.attr = attr
etc...
Am I right? Thanks a lot!