Avaiga / taipy-gui

Graphical User Interface generator for Taipy
Apache License 2.0
60 stars 20 forks source link

BUG- Weird interaction between clients with invoke long callback #976

Closed FlorianJacta closed 1 year ago

FlorianJacta commented 1 year ago

Description

When two applications run an invoke_long_callback; there are strange behaviors with the client.

TaipyGuiWarning: Empty session id, using global scope instead.
TaipyGuiWarning: Empty session id, using global scope instead.
TaipyGuiWarning: Empty session id, using global scope instead.
TaipyGuiWarning: Empty session id, using global scope instead.

How to reproduce

Run this code and observe the value of each client. The number should always rise in both.

from taipy.gui import Gui, invoke_long_callback, notify, navigate
import time 

page = """
<|{value}|>
"""

def update(state, status):
    state.value += 1

def iddle():
     while True:
        time.sleep(1)

def on_init(state):
    invoke_long_callback(state, iddle, [], update, [], 1000)

value = 0

if __name__ == "__main__":
    gui = Gui(page=page)
    gui.run(title='Raising number')

Expected behavior Each context should be kept from the others.

Screenshots pb_client

Runtime environment Taipy GUI 3.0.dev4

dinhlongviolin1 commented 1 year ago

I have tested this one. I could not replicate the issue and it might be on your side due to the missing session id. Please reopen the issue if the error still persisted on your side. Here is the code that I used.

from src.taipy.gui import Gui, invoke_long_callback
import time

page = """
<|{value}|>
"""

def update(state, status):
    state.value += 1

def iddle():
    while True:
        time.sleep(0.5)

def on_init(state):
    invoke_long_callback(state, iddle, [], update, [], 500)

value = 0

if __name__ == "__main__":
    gui = Gui(page=page)
    gui.run(title="Raising number", server_config={"socketio": {"ping_interval": 0.5}})
FlorianJacta commented 1 year ago

Not working with this code. I don't think this is on my side. It is replicated even on Taipy Cloud. Have you created two different clients and have yet to see the weird changes?

dinhlongviolin1 commented 1 year ago

Not working with this code. I don't think this is on my side. It is replicated even on Taipy Cloud. Have you created two different clients and have yet to see the weird changes?

I have tried on more than 3 separate clients on 3 browsers (chrome, safari, firefox) at the same time and it works perfectly on my side.

FredLL-Avaiga commented 1 year ago

tried @dinhlongviolin1 code and can't see the issue

FlorianJacta commented 1 year ago

@FredLL-Avaiga @dinhlongviolin1 At one point, this morning, it was working fine. I put on the console localStorage.clear() and the bug reappeared. (Maybe, it has nothing to do with it)

dinhlongviolin1 commented 1 year ago

Thanks for reporting. We will have a look into it. What I suspect that the bug appears when the session id is not properly initialized.