gradio-app / gradio

Build and share delightful machine learning apps, all in Python. 🌟 Star to support our work!
http://www.gradio.app
Apache License 2.0
32.52k stars 2.44k forks source link

`every` stops working after a few iterations #8703

Closed skye0402 closed 3 months ago

skye0402 commented 3 months ago

Describe the bug

I applied every on a gr.Markdown() to rotate text every 10s. This works for a while but then stops. I see no error in the Chrome Debugger and wonder what it could be. Maybe I'm using it wrong? Below is the code. Note that I have 2 consecutive chat_view.load() of which I'm not sure if this is correct.

As said, it works but not for long. I use gr.Blocks and chat_view is the complete UI (gr.Blocks() as chat_view).

Have you searched existing issues? 🔎

Reproduction

...
        # ---------------------- Event handling: Loading page
        chat_view.load(
            set_user_data,  
            inputs=[state,
                    feature_selector,
                    temp_slider,
                    sldr_chunk_size,
                    sldr_chunk_overlap,
                    sldr_k_top,
                    system_role,
                    selected_model], 
            outputs=[
                model_selector,
                feature_selector,
                temp_slider,
                sldr_chunk_size,
                sldr_chunk_overlap,
                sldr_k_top,
                system_role,
                logo_box,
                user_info_tab,
                slide_gen_tab,
                negative_prompt, 
                inference_steps, 
                guidance_scale, 
                img_width, 
                img_height, 
                remaining
            ]
        )
        chat_view.load(
            fill_logo_box,
            inputs=[state],
            outputs=[logo_box],
            every=10)
    return chat_view

def fill_logo_box(state: dict)->str:
    """ Fills the info box at the right bottom of the screen """
    rnd = random.randint(0, len(state.get("announcements"))-1)
    info = info_message(state=state)
    server = state.get("s4_server_message", "")
    announcement = state.get("announcements")[rnd]
    jwt_data = state.get("jwt", None)
    session_expiry = 0
    if jwt_data:
        session_expiry = jwt_data.get("exp", 0)
    content = f"{LOGO_MARKDOWN}\n{info}\n\r{announcement}\n{server}<small> ({MY_PODNAME})</small>"
    return content

Screenshot

image

Logs

No response

System Info

Gradio is 4.36.1

Severity

I can work around it

abidlabs commented 3 months ago

Hi @skye0402 we just merged in a PR with some fixes for every into main. Could you see if the issue is resolved on main? You can install gradio from main by following the instructions here: https://www.gradio.app/main/docs/interface

abidlabs commented 3 months ago

Closing for lack of follow up, we can reopen if needed