2121if MYPY :
2222 from typing import Any
2323
24- __all__ = ["Empty " , "Full " , "Queue" ]
24+ __all__ = ["EmptyError " , "FullError " , "Queue" ]
2525
2626
27- class Empty (Exception ):
27+ class EmptyError (Exception ):
2828 "Exception raised by Queue.get(block=0)/get_nowait()."
2929 pass
3030
3131
32- class Full (Exception ):
32+ class FullError (Exception ):
3333 "Exception raised by Queue.put(block=0)/put_nowait()."
3434 pass
3535
@@ -134,16 +134,16 @@ def put(self, item, block=True, timeout=None):
134134 If optional args 'block' is true and 'timeout' is None (the default),
135135 block if necessary until a free slot is available. If 'timeout' is
136136 a non-negative number, it blocks at most 'timeout' seconds and raises
137- the Full exception if no free slot was available within that time.
137+ the FullError exception if no free slot was available within that time.
138138 Otherwise ('block' is false), put an item on the queue if a free slot
139- is immediately available, else raise the Full exception ('timeout'
139+ is immediately available, else raise the FullError exception ('timeout'
140140 is ignored in that case).
141141 """
142142 with self .not_full :
143143 if self .maxsize > 0 :
144144 if not block :
145145 if self ._qsize () >= self .maxsize :
146- raise Full ()
146+ raise FullError ()
147147 elif timeout is None :
148148 while self ._qsize () >= self .maxsize :
149149 self .not_full .wait ()
@@ -154,7 +154,7 @@ def put(self, item, block=True, timeout=None):
154154 while self ._qsize () >= self .maxsize :
155155 remaining = endtime - time ()
156156 if remaining <= 0.0 :
157- raise Full
157+ raise FullError ()
158158 self .not_full .wait (remaining )
159159 self ._put (item )
160160 self .unfinished_tasks += 1
@@ -166,15 +166,15 @@ def get(self, block=True, timeout=None):
166166 If optional args 'block' is true and 'timeout' is None (the default),
167167 block if necessary until an item is available. If 'timeout' is
168168 a non-negative number, it blocks at most 'timeout' seconds and raises
169- the Empty exception if no item was available within that time.
169+ the EmptyError exception if no item was available within that time.
170170 Otherwise ('block' is false), return an item if one is immediately
171- available, else raise the Empty exception ('timeout' is ignored
171+ available, else raise the EmptyError exception ('timeout' is ignored
172172 in that case).
173173 """
174174 with self .not_empty :
175175 if not block :
176176 if not self ._qsize ():
177- raise Empty ()
177+ raise EmptyError ()
178178 elif timeout is None :
179179 while not self ._qsize ():
180180 self .not_empty .wait ()
@@ -185,7 +185,7 @@ def get(self, block=True, timeout=None):
185185 while not self ._qsize ():
186186 remaining = endtime - time ()
187187 if remaining <= 0.0 :
188- raise Empty ()
188+ raise EmptyError ()
189189 self .not_empty .wait (remaining )
190190 item = self ._get ()
191191 self .not_full .notify ()
@@ -195,15 +195,15 @@ def put_nowait(self, item):
195195 """Put an item into the queue without blocking.
196196
197197 Only enqueue the item if a free slot is immediately available.
198- Otherwise raise the Full exception.
198+ Otherwise raise the FullError exception.
199199 """
200200 return self .put (item , block = False )
201201
202202 def get_nowait (self ):
203203 """Remove and return an item from the queue without blocking.
204204
205205 Only get an item if one is immediately available. Otherwise
206- raise the Empty exception.
206+ raise the EmptyError exception.
207207 """
208208 return self .get (block = False )
209209
0 commit comments