I have a hard computational task that I need to do when processing the request. And after its completion, the result must be recorded in the database. How to do it right? Can it be executed in the current thread?

  • one
    Submissions must respond as quickly as possible. It is better to shift heavy calculations to background tasks using uWSGI Pools, Huey or Celery. - Sergey Gornostaev

1 answer 1

Better in a separate thread or process. You can also use celery for such tasks, but I think this is not your option. Look at https://stackoverflow.com/questions/2046603/is-it-possible-to-run-function-in-a-subprocess-with-threading-or-writing-a-se