Describe the problem
When I switch quickly between the HTML pages the connection drops and the Python script quits.
The same happens when I try to hibernate the laptop with the app with eel.js left opened. Other Python scripts keep running when I enter the system after the hibernation, so it's surely eel.js.
@samuelhwilliams @ChrisKnott
Desktop (please complete the following information):
I've experienced this issue as well, although infrequently when alternating quickly between pages.
OS: Windows 10
Browser: Chrome
Eel Version: 0.12.2
@becurrie Have you encountered any fixes?
Sounds like a safe bet this is a bug. I'll try to look into it when I next have some time - sorry that you're experiencing these issues.
@samuelhwilliams I'm not entirely sure but it seems to me like a good place to start is in the _websocket_close method, it looks like this is where my issues stemmed from at least, whenever I refresh or go to another page, the web-socket is closed and reinitialized (I think, correct me If I'm wrong).
I'm using a custom close callback but it's doing basically the same thing as the default behaviour, it looks like this (I've added some print statements to try and lock down the issue).
def close_callback(*args, **kwargs):
print("IN CLOSE CALLBACK")
print("SLEEPING FOR 1 SEC")
eel.sleep(1)
# Check for websockets now.
if len(eel._websockets) == 0:
print("0 WEBSOCKETS, EXITING.")
set_active_state(state=False). # <-- My custom functionality.
print("-------------")
sys.exit()
print("-------------")
So with this, if I start clicking quickly on a link within my frontend, I get the following:
IN CLOSE CALLBACK.
SLEEPING FOR 1 SEC
IN CLOSE CALLBACK.
SLEEPING FOR 1 SEC
-----------------
IN CLOSE CALLBACK.
SLEEPING FOR 1 SEC
0 WEBSOCKETS, EXITING.
-----------------
Maybe the function is just being executed in quick succession, causing the list _websockets to be checked before the socket is actually ready and available in the list.
Is there any updates on this one? I'm looking into porting a project over to the Eel framework, but this issue definitely poses some issues for end users!
Hey @MishaTreedye @becurrie - I've put up this PR with a possible patch: https://github.com/samuelhwilliams/Eel/pull/337
I'm going to let it mull in my head for a bit while I try to think of a way to test this. I've so far struggled to set up decent testing for Eel but I'd really like to crack that soon.
If you're happy/comfortable to install Eel locally could you test that branch against your own code and see if it works for you?
@samuelhwilliams Hey! Thanks for the quick reply and the even quicker PR :)
The changes in #337 seem to have fixed the issue I was running into 馃憤
Released as v0.13.1
Most helpful comment
@samuelhwilliams Hey! Thanks for the quick reply and the even quicker PR :)
The changes in #337 seem to have fixed the issue I was running into 馃憤