guipenedo HF Staff commited on
Commit
6f36141
·
1 Parent(s): cb70373

queue changes

Browse files
Files changed (1) hide show
  1. app.py +12 -9
app.py CHANGED
@@ -244,9 +244,9 @@ def on_next(docs_cache, idx: int, reader_iter, require_has_math: bool, require_h
244
 
245
 
246
  with gr.Blocks() as demo:
247
- idx_state = gr.State(value=-1)
248
- docs_state = gr.State(value=[])
249
- iter_state = gr.State(value=None)
250
 
251
  with gr.Row():
252
  # Full-width controls row for navigation
@@ -277,17 +277,20 @@ with gr.Blocks() as demo:
277
  right_iframe = gr.HTML(label="Original Page")
278
  right_infoboxes = gr.JSON(label="Infoboxes")
279
 
280
- language_select.change(on_select_language, inputs=[language_select, require_has_math, require_has_infobox], outputs=[idx_state, docs_state, iter_state, left_text, left_meta, header_md, right_markdown, right_infoboxes, right_iframe])
281
- demo.load(on_select_language, inputs=[language_select, require_has_math, require_has_infobox], outputs=[idx_state, docs_state, iter_state, left_text, left_meta, header_md, right_markdown, right_infoboxes, right_iframe])
282
- find_btn.click(on_find, inputs=[docs_state, idx_state, iter_state, id_input, require_has_math, require_has_infobox], outputs=[idx_state, docs_state, iter_state, left_text, left_meta, header_md, right_markdown, right_infoboxes, right_iframe])
283
 
284
  # Visibility toggles driven directly by checkbox changes
285
  show_wiki.change(lambda v: gr.update(visible=v), inputs=[show_wiki], outputs=[right_markdown])
286
  show_preview.change(lambda v: gr.update(visible=v), inputs=[show_preview], outputs=[right_iframe])
287
  show_infoboxes.change(lambda v: gr.update(visible=v), inputs=[show_infoboxes], outputs=[right_infoboxes])
288
- prev_btn.click(on_prev, inputs=[docs_state, idx_state, iter_state, require_has_math, require_has_infobox], outputs=[idx_state, docs_state, iter_state, left_text, left_meta, header_md, right_markdown, right_infoboxes, right_iframe])
289
- next_btn.click(on_next, inputs=[docs_state, idx_state, iter_state, require_has_math, require_has_infobox], outputs=[idx_state, docs_state, iter_state, left_text, left_meta, header_md, right_markdown, right_infoboxes, right_iframe])
 
 
 
290
 
291
 
292
  if __name__ == "__main__":
293
- demo.launch(server_name="0.0.0.0", server_port=7641)
 
244
 
245
 
246
  with gr.Blocks() as demo:
247
+ idx_state = gr.State(value=-1, time_to_live=900)
248
+ docs_state = gr.State(value=[], time_to_live=900)
249
+ iter_state = gr.State(value=None, time_to_live=900)
250
 
251
  with gr.Row():
252
  # Full-width controls row for navigation
 
277
  right_iframe = gr.HTML(label="Original Page")
278
  right_infoboxes = gr.JSON(label="Infoboxes")
279
 
280
+ language_select.change(on_select_language, inputs=[language_select, require_has_math, require_has_infobox], outputs=[idx_state, docs_state, iter_state, left_text, left_meta, header_md, right_markdown, right_infoboxes, right_iframe], concurrency_limit=1)
281
+ demo.load(on_select_language, inputs=[language_select, require_has_math, require_has_infobox], outputs=[idx_state, docs_state, iter_state, left_text, left_meta, header_md, right_markdown, right_infoboxes, right_iframe], concurrency_limit=1)
282
+ find_btn.click(on_find, inputs=[docs_state, idx_state, iter_state, id_input, require_has_math, require_has_infobox], outputs=[idx_state, docs_state, iter_state, left_text, left_meta, header_md, right_markdown, right_infoboxes, right_iframe], concurrency_limit=1)
283
 
284
  # Visibility toggles driven directly by checkbox changes
285
  show_wiki.change(lambda v: gr.update(visible=v), inputs=[show_wiki], outputs=[right_markdown])
286
  show_preview.change(lambda v: gr.update(visible=v), inputs=[show_preview], outputs=[right_iframe])
287
  show_infoboxes.change(lambda v: gr.update(visible=v), inputs=[show_infoboxes], outputs=[right_infoboxes])
288
+ prev_btn.click(on_prev, inputs=[docs_state, idx_state, iter_state, require_has_math, require_has_infobox], outputs=[idx_state, docs_state, iter_state, left_text, left_meta, header_md, right_markdown, right_infoboxes, right_iframe], concurrency_limit=1)
289
+ next_btn.click(on_next, inputs=[docs_state, idx_state, iter_state, require_has_math, require_has_infobox], outputs=[idx_state, docs_state, iter_state, left_text, left_meta, header_md, right_markdown, right_infoboxes, right_iframe], concurrency_limit=1)
290
+
291
+ # Enable global queue to coordinate concurrent requests safely
292
+ demo.queue(default_concurrency_limit=1, max_size=128)
293
 
294
 
295
  if __name__ == "__main__":
296
+ demo.launch(server_name="0.0.0.0", server_port=7641, state_session_capacity=5000)