je vais regarder a quoi ca sert yield
This commit is contained in:
parent
e181bd1ba4
commit
fe35650452
@ -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':
|
||||
print(message)
|
||||
yield f"data: {message['data'].decode()}\n\n"
|
||||
except redis.exceptions.ConnectionError as e:
|
||||
print(f"Error connecting to Redis: {e}")
|
||||
|
||||
|
||||
# the end
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user