Answer the question
In order to leave comments, you need to log in
Producer as a separate thread?
Very often I see the following story in the code:
a project that uses the producer-consumer pattern makes the producer a separate thread, here is even an example from the first link on the request "Producer-consumer in python".
Due to my lack of education in this regard, it seems surprising to me that the logic of replenishing the queue with tasks in a separate thread: why not leave it in the main? I assume that it is necessary to take out the logic of the producer (target or inheritance) in a separate thread when our main thread should not be clogged with blocking. Is it so?
If not, or I'm partially right, then please explain in which cases it is better to call the producer's logic in the main thread, and in which to take it out.
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question