Pushes the given link to the queue. Position in the queue is determined by priority. Equal ranks are sorted FIFO or FILO. With priority=1.0 and FILO, the link is inserted to the queue. With priority=0.0 and FIFO, the link is appended to the queue.
(self, link, priority=1.0, sort=FILO)
| 3131 | return len(self._queue) == 0 |
| 3132 | |
| 3133 | def push(self, link, priority=1.0, sort=FILO): |
| 3134 | """ Pushes the given link to the queue. |
| 3135 | Position in the queue is determined by priority. |
| 3136 | Equal ranks are sorted FIFO or FILO. |
| 3137 | With priority=1.0 and FILO, the link is inserted to the queue. |
| 3138 | With priority=0.0 and FIFO, the link is appended to the queue. |
| 3139 | """ |
| 3140 | if not isinstance(link, Link): |
| 3141 | link = Link(url=link) |
| 3142 | dt = time.time() |
| 3143 | dt = sort == FIFO and dt or 1 / dt |
| 3144 | bisect.insort(self._queue, (1 - priority, dt, link)) |
| 3145 | self._queued[link.url] = True |
| 3146 | |
| 3147 | def pop(self, remove=True): |
| 3148 | """ Returns the next Link queued to visit and removes it from the queue. |