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):
91
91
return n
92
92
93
93
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
+ """
95
105
self .mutex .acquire ()
96
106
n = not self ._qsize ()
97
107
self .mutex .release ()
98
108
return n
99
109
100
110
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
+ """
102
119
self .mutex .acquire ()
103
120
n = 0 < self .maxsize == self ._qsize ()
104
121
self .mutex .release ()
You can’t perform that action at this time.
0 commit comments