@@ -97,21 +97,18 @@ async def _get(self, path=None):
97
97
QueryStringSocketHandler .send_updates ({'kernel_id' : kernel_id , 'payload' : self .request .query })
98
98
# Send rendered cell to frontend
99
99
if len (rendered_cache ) > 0 :
100
- self .write ('' .join (rendered_cache ))
101
- self .flush ()
100
+ yield '' .join (rendered_cache )
102
101
103
102
# Wait for current running cell finish and send this cell to
104
103
# frontend.
105
104
rendered , rendering = await render_task
106
105
if len (rendered ) > len (rendered_cache ):
107
106
html_snippet = '' .join (rendered [len (rendered_cache ):])
108
- self .write (html_snippet )
109
- self .flush ()
107
+ yield html_snippet
110
108
111
109
# Continue render cell from generator.
112
110
async for html_snippet , _ in rendering :
113
- self .write (html_snippet )
114
- self .flush ()
111
+ yield html_snippet
115
112
self .flush ()
116
113
117
114
else :
@@ -136,8 +133,7 @@ def time_out():
136
133
can be used in a template to give feedback to a user
137
134
"""
138
135
139
- self .write ('<script>voila_heartbeat()</script>\n ' )
140
- self .flush ()
136
+ yield '<script>voila_heartbeat()</script>\n '
141
137
142
138
kernel_env [ENV_VARIABLE .VOILA_PREHEAT ] = 'False'
143
139
kernel_env [ENV_VARIABLE .VOILA_BASE_URL ] = self .base_url
@@ -154,14 +150,9 @@ def time_out():
154
150
async for html_snippet , _ in gen .generate_content_generator (
155
151
kernel_id , kernel_future , time_out
156
152
):
157
- self .write (html_snippet )
158
- self .flush ()
153
+ yield html_snippet
159
154
# we may not want to consider not flusing after each snippet, but add an explicit flush function to the jinja context
160
155
# yield # give control back to tornado's IO loop, so it can handle static files or other requests
161
- self .flush ()
162
-
163
- if self .is_fps :
164
- return self .return_html ()
165
156
166
157
class _VoilaHandler :
167
158
is_fps = False
@@ -203,4 +194,9 @@ def should_use_rendered_notebook(
203
194
class VoilaHandler (_VoilaHandler , JupyterHandler ):
204
195
@tornado .web .authenticated
205
196
async def get (self , path = None ):
206
- return await _get (self , path = path )
197
+ it = _get (self , path = path )
198
+ async for html in it :
199
+ self .write (html )
200
+ self .flush ()
201
+
202
+ return it
0 commit comments