We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents 8ac4d93 + 653c168 commit 217112dCopy full SHA for 217112d
tutorial.md
@@ -1090,13 +1090,15 @@ def ajax_endpoint(environ, start_response):
1090
('Content-Type', 'application/json')
1091
]
1092
1093
- try:
1094
- datum = data_source.get(timeout=5)
1095
- except Empty:
1096
- datum = []
1097
-
1098
start_response(status, headers)
1099
- return json.dumps(datum)
+
+ while True:
+ try:
+ datum = data_source.get(timeout=5)
+ yield json.dumps(datum) + '\n'
+ except Empty:
1100
+ pass
1101
1102
1103
gevent.spawn(producer)
1104
0 commit comments