From fe356504527995a45b7e2565e99a7c6f580958fb Mon Sep 17 00:00:00 2001 From: piair Date: Tue, 3 Oct 2023 00:32:59 +0200 Subject: [PATCH] je vais regarder a quoi ca sert yield --- Flask/app.py | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/Flask/app.py b/Flask/app.py index f2df2f0..a706de9 100644 --- a/Flask/app.py +++ b/Flask/app.py @@ -20,13 +20,11 @@ pubsub = redis_client.pubsub() pubsub.subscribe('console') def generate_output(): - while 1 : - try: - for message in pubsub.listen(): - if message['type'] == 'message': - yield f"data: {message['data'].decode()}\n\n" - except redis.exceptions.ConnectionError as e: - print(f"Error connecting to Redis: {e}") + for message in pubsub.listen(): + if message['type'] == 'message': + print(message) + yield f"data: {message['data'].decode()}\n\n" + # the end