I want my thread to sleep when a queue is empty and when it puts any data in it, then wake up Are there. Should I use the condition object? I have never used this object before, and I can not find a simple example in Python.
If the queue object in question is bound by the name q
, just call q.get ()
: As long as the queue is empty, it will sleep patiently, then return the first item of the queue as soon as the queue to empty one from another thread . Put (whatever)
executes, although this can not be clearly explained, this behavior of the default of .get ()
Is when you do it without any Call, and actually read the most popular method for a thread from a queue (this is the reason that it was made default in the first place; -)
Comments
Post a Comment