-
-
Notifications
You must be signed in to change notification settings - Fork 151
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ensure generators are closed #218
Comments
ha, please follow me : import asyncio
from quart import Quart, make_response, stream_with_context
from datetime import datetime
app = Quart(__name__)
@app.route('/')
async def sub():
@stream_with_context
async def data_stream():
try:
while True:
print("Sending Data")
yield "data: {ok: true}\n\n".encode()
await asyncio.sleep(1)
finally:
print("Exited Gen")
response = await make_response(data_stream())
response.timeout = None
response.headers['Content-Type'] = 'text/event-stream'
return response
if __name__ == "__main__":
app.run() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The text was updated successfully, but these errors were encountered: