pubsub.subscribe('chat')
for message in pubsub.listen():
    print(message)
yield 'data: %s\n\n' % message['data']

@app.route('/stream')
def stream():
    return flask.Response(event_stream(), mimetype='text/event-stream')
Как закрыть соединение Server-Send Events в Flask?