i have question, can django multi-thread works?
here want do: click button on web page, there functions in model.py starts run, example, crawl data internet, when finished, returns user results.
i wonder have open new thread execute functions in model.py, can tell me how it? thank much.
- yes can multi-thread, 1 uses celery equivalent. you can read how in celery-django tutorial.
- it rare actually want force user wait website. while it's better risks timeout.
here's example of you're describing.
user sends request django receives => spawns thread else. main thread finishes && other thread finishes ... (later upon completion of both tasks) response sent user package.
better way:
user sends request django receives => lets celery know "hey! this!" main thread finishes response sent user ...(later) user receives balance of transaction
Comments
Post a Comment