File tree Expand file tree Collapse file tree 1 file changed +19
-2
lines changed
Expand file tree Collapse file tree 1 file changed +19
-2
lines changed Original file line number Diff line number Diff line change @@ -91,14 +91,31 @@ def qsize(self):
9191 return n
9292
9393 def empty (self ):
94- """Return True if the queue is empty, False otherwise (not reliable!)."""
94+ """Return True if the queue is empty, False otherwise (not reliable!).
95+
96+ This method is likely to be removed at some point. Use qsize() == 0
97+ as a direct substitute, but be aware that either approach risks a race
98+ condition where a queue can grow before the result of empty() or
99+ qsize() can be used.
100+
101+ To create code that needs to wait for all queued tasks to be
102+ completed, the preferred technique is to use the join() method.
103+
104+ """
95105 self .mutex .acquire ()
96106 n = not self ._qsize ()
97107 self .mutex .release ()
98108 return n
99109
100110 def full (self ):
101- """Return True if the queue is full, False otherwise (not reliable!)."""
111+ """Return True if the queue is full, False otherwise (not reliable!).
112+
113+ This method is likely to be removed at some point. Use qsize() == n
114+ as a direct substitute, but be aware that either approach risks a race
115+ condition where a queue can shrink before the result of full() or
116+ qsize() can be used.
117+
118+ """
102119 self .mutex .acquire ()
103120 n = 0 < self .maxsize == self ._qsize ()
104121 self .mutex .release ()
You can’t perform that action at this time.
0 commit comments