///
Analise o código em Phyton a seguir e marque a alternativa correta.
import asyncio
# uma fila
fila_de_eventos = asyncio.Queue()
# Prod
async def produtor(nome):
for i in range(3):
evento = f"Evento {i} de {nome}"
print(f"[Produtor {nome}] Publicando: {evento}")
await fila_de_eventos.put(evento)
await asyncio.sleep(1)
# Cons
async def consumidor(nome):
while True:
evento = await fila_de_eventos.get()
print(f"[Consumidor {nome}] Processando: {evento}")
await asyncio.sleep(2)
fila_de_eventos.task_done()
# Função principal
async def main():
consumidores = [asyncio.create_task(consumidor(f"Consumidor {i}")) for i in range(2)]
produtores = [asyncio.create_task(produtor(f"Produtor {i}")) for i in range(2)]
await asyncio.gather(*produtores)
await fila_de_eventos.join()
for c in consumidores:
c.cancel()
asyncio.run(main())