Takes a uid from the told queue if not empty, else from the older asked, then adds it to the asked queue.
(self)
| 326 | self.asked.clear() |
| 327 | |
| 328 | def ask(self) -> str: |
| 329 | """Takes a uid from the told queue if not empty, else from the older asked, |
| 330 | then adds it to the asked queue. |
| 331 | """ |
| 332 | if self.told: |
| 333 | uid = self.told.popleft() |
| 334 | elif self.asked: |
| 335 | uid = next(iter(self.asked)) |
| 336 | else: |
| 337 | raise RuntimeError("Both asked and told queues are empty.") |
| 338 | self.asked.add(uid) |
| 339 | return uid |
| 340 | |
| 341 | def tell(self, uid: str) -> None: |
| 342 | """Removes the uid from the asked queue and adds to the told queue""" |