Spaces:
Sleeping
How to use run_forever in gradio 3.35.2
Hi.
run_forever
is not available in gradio 3.35.2
: AttributeError: 'Blocks' object has no attribute 'run_forever'
Is there something similar in gradio 3.35.2
or how would I go about for a quick hack myself? I took a look at the docs and was not able to find anything.
Thanks.
maybe cc @freddyaboulton
Hi @mikeee !
This space is using an experimental api. We ended up adding a parameter called every to all the event listeners so you can configure how often the event should run.
So to achieve something like this space on the latest version of gradio you would do:
with gr.Blocks() as demo:
demo.launch(fn,…,every=2)
demo.queue().launch()
Sorry for the formatting - I’m on mobile.
@freddyaboulton BTW feel free to open a PR on this repo to upgrade it to the new way of doing things! Thanks:)
thanks a lot @freddyaboulton , closing this for now @mikeee please re-open if it's not fixed
Thanks @freddyaboulton @julien-c !
@freddyaboulton
's method works. Here is the slightly modified example from https://www.gradio.app/docs/blocks) for doing run_forever
:
import gradio as gr
import datetime
with gr.Blocks() as demo:
def get_time():
return datetime.datetime.now().time()
dt = gr.Textbox(label="Current time")
demo.load(get_time, inputs=[], outputs=dt, every=1)
# for every to take effect, queue must be enabled
demo.queue().launch()