@@ 194-222 (lines=29) @@ | ||
191 | Full = BaseQueue.Full |
|
192 | max_timeout = 0.3 |
|
193 | ||
194 | def __init__(self, name, amqp_url='amqp://guest:guest@localhost:5672/%2F', |
|
195 | maxsize=0, lazy_limit=True): |
|
196 | """ |
|
197 | Constructor for a AmqpQueue. |
|
198 | ||
199 | Default for python 3. |
|
200 | ||
201 | amqp_url: https://www.rabbitmq.com/uri-spec.html |
|
202 | maxsize: an integer that sets the upperbound limit on the number of |
|
203 | items that can be placed in the queue. |
|
204 | lazy_limit: as rabbitmq is shared between multipul instance, for a strict |
|
205 | limit on the number of items in the queue. PikaQueue have to |
|
206 | update current queue size before every put operation. When |
|
207 | `lazy_limit` is enabled, PikaQueue will check queue size every |
|
208 | max_size / 10 put operation for better performace. |
|
209 | """ |
|
210 | self.name = name |
|
211 | self.amqp_url = amqp_url |
|
212 | self.maxsize = maxsize |
|
213 | self.lock = threading.RLock() |
|
214 | ||
215 | self.lazy_limit = lazy_limit |
|
216 | if self.lazy_limit and self.maxsize: |
|
217 | self.qsize_diff_limit = int(self.maxsize * 0.1) |
|
218 | else: |
|
219 | self.qsize_diff_limit = 0 |
|
220 | self.qsize_diff = 0 |
|
221 | ||
222 | self.reconnect() |
|
223 | ||
224 | def reconnect(self): |
|
225 | """Reconnect to rabbitmq server""" |
|
@@ 61-89 (lines=29) @@ | ||
58 | Full = BaseQueue.Full |
|
59 | max_timeout = 0.3 |
|
60 | ||
61 | def __init__(self, name, amqp_url='amqp://guest:guest@localhost:5672/%2F', |
|
62 | maxsize=0, lazy_limit=True): |
|
63 | """ |
|
64 | Constructor for a PikaQueue. |
|
65 | ||
66 | Not works with python 3. Default for python 2. |
|
67 | ||
68 | amqp_url: https://www.rabbitmq.com/uri-spec.html |
|
69 | maxsize: an integer that sets the upperbound limit on the number of |
|
70 | items that can be placed in the queue. |
|
71 | lazy_limit: as rabbitmq is shared between multipul instance, for a strict |
|
72 | limit on the number of items in the queue. PikaQueue have to |
|
73 | update current queue size before every put operation. When |
|
74 | `lazy_limit` is enabled, PikaQueue will check queue size every |
|
75 | max_size / 10 put operation for better performace. |
|
76 | """ |
|
77 | self.name = name |
|
78 | self.amqp_url = amqp_url |
|
79 | self.maxsize = maxsize |
|
80 | self.lock = threading.RLock() |
|
81 | ||
82 | self.lazy_limit = lazy_limit |
|
83 | if self.lazy_limit and self.maxsize: |
|
84 | self.qsize_diff_limit = int(self.maxsize * 0.1) |
|
85 | else: |
|
86 | self.qsize_diff_limit = 0 |
|
87 | self.qsize_diff = 0 |
|
88 | ||
89 | self.reconnect() |
|
90 | ||
91 | def reconnect(self): |
|
92 | """Reconnect to rabbitmq server""" |