data-structures-algorithms-python icon indicating copy to clipboard operation
data-structures-algorithms-python copied to clipboard

Infinite loop thread in 6_Queue Exercise food_ordering_system.py

Open udipta opened this issue 3 years ago • 1 comments

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)

udipta avatar May 30 '22 17:05 udipta

Did you able to solve it by this method? Please attach your solution if possible. Thank you!

sid-pandya avatar Jun 18 '22 20:06 sid-pandya