data-structures-algorithms-python
data-structures-algorithms-python copied to clipboard
Infinite loop thread in 6_Queue Exercise food_ordering_system.py
https://github.com/codebasics/data-structures-algorithms-python/blob/master/data_structures/6_Queue/Exercise/food_ordering_system.py
Issue:
def serve_orders():
time.sleep(1)
while True:
order = food_order_queue.dequeue()
print("Now serving: ",order)
time.sleep(2)
Proposed below:
def serve_orders():
time.sleep(1)
while not food_order_queue.is_empty():
order = food_order_queue.dequeue()
print("Now serving: ",order)
time.sleep(2)
Did you able to solve it by this method? Please attach your solution if possible. Thank you!