Skip to content

Multi threading (multiple requests) problem. #338

Answered by snakers4
fadyscube asked this question in Q&A
Discussion options

You must be logged in to vote

Hi,

First of all it is better to use the ONNX model, since it requires less dependencies, onnx-runtime weighs much less, and the onnx model is 2-3 times faster.

Secondly, the model itself is a reference to an underlying lower level object. I am not familiar with how django handles concurrency (is it thread-safe, does it use threads, processes, asyncio, etc). But it looks like that somehow several requests are made at the same time to the same underlying model object, which entails a collision.

There are many ways and instruments in python to do this correctly:

  • If you process whole files, having a messaging system like celery or rabbit-mq may work well. A separate process (worker, consum…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by snakers4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
help wanted Extra attention is needed
2 participants
Converted from issue

This discussion was converted from issue #337 on May 05, 2023 06:17.