1
2
3 from Queue import Queue, Full, Empty
4
5 __all__=['ClosingQueue', 'Closed', 'Full', 'Empty']
6
8 """exception raised when trying to put to a closed queue"""
9
11 """a L{Queue} that can be L{close}d.
12
13 When the queue is closed, attempting to L{put} additional items will raise
14 L{Closed}.
15
16 A newly-created queue is open.
17 """
18
19 - def _init(self, *args, **kwargs):
20 self._closed=False
21 Queue._init(self, *args, **kwargs)
22
24 """Return True if the queue is closed, False otherwise (not reliable!)."""
25 self.mutex.acquire()
26 n = self._closed
27 self.mutex.release()
28 return n
29
31 """close the queue to new items"""
32
33 self.mutex.acquire()
34 try:
35 self._closed=True
36 finally:
37 self.mutex.release()
38
39
40
41 - def _put(self, item):
42 if self._closed: raise Closed
43 else: return Queue._put(self, item)
44
45
46
47
48