Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- queue = []
- def make_producer():
- while True:
- print("I don't want these any more")
- for i in range(3):
- print(f"I'll drop this {i} on the ground")
- queue.append(i)
- print("Now I will run away")
- yield consumer
- def make_consumer():
- while True:
- print("I hunger")
- while queue:
- x = queue.pop()
- print(f"Mm, tasty {x}")
- print("Nap time")
- yield producer
- producer = make_producer()
- consumer = make_consumer()
- g = producer
- count = 0
- while True:
- g = next(g)
- count += 1
- if count > 20: break
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement