why not:
```python
while not queue.empty():
```
?