question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Setting block=False at eel.start() gives error

See original GitHub issue

Eel version 0.14.0

Describe the bug When the app is started with block=False, It gives the error as Error site can't be reached Issue similar to this one: #167

To Reproduce Steps to reproduce the behavior: try to start the app with eel.start("index.html",block=True) As show in the code snippet below:

import pyautogui
import eel
import datetime
import time
eel.init('front-end')
#--------------------------------------------------------------------------
#Problematic line
eel.start('index.html',size=(500,500),block=False) 
#this works fine as long as it is started without the block=False
#--------------------------------------------------------------------------
@eel.expose
def handshake(secs):
    secs=float(secs)
    while secs:
        eel.sleep(1)
        pyautogui.press('f15')
        
        print(f"Time: {datetime.timedelta(seconds=float(secs))}")
        return f"Time: {datetime.timedelta(seconds=float(secs))}"

Expected behavior The app should work normally but it gives LocalHost error

Screenshots image

Desktop (please complete the following information):

  • OS: windows 11
  • Browser Google Chrome

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:6

github_iconTop GitHub Comments

1reaction
bernardolansingcommented, Mar 27, 2022

Hello @thatfloflo. Thank you for sharing your solution. For me, it worked but only for the first time I ran my code. After that, localhost would be refused again. But you gave me the ideia to use eel.sleep(1.0) just after eel.start being called. I am not sure about the 1.0, but this way it started to work, at least for me. Worth trying.

Update: nah, this just makes it load the html, but JS is still not loaded, no matter what time interval I choose to eel.sleep. Does anyone have any tip? I really need to get this working soon…

1reaction
thatfloflocommented, Mar 21, 2022

I suspect your script might just finish and quit before you ever get around to connecting. Try something like this:

import eel
import gevent
eel.start('index.html',size=(500,500),block=False)
gevent.get_hub().join()

If you don’t have eel block then you need to make sure the event loop is entered yourself as far as I can tell. This also leaves it up to you to quit the event loop when the last socket is closed (or whatever conditions/events happen that should produce that behaviour).

Read more comments on GitHub >

github_iconTop Results From Across the Web

Blocking False is not working · Issue #477 · python-eel/Eel
Open up python and call the eel.init("web") function · Then call the eel.start("index.html", blocking=false) · Click on reload (F5) or open the ...
Read more >
python eel - and 404 when block=False - Stack Overflow
It gives me a 404 error. But when I start eel with this basic pattern: eel.start("index_blank.html"). it will work. When I use block=False ......
Read more >
How to use the eel.init function in Eel - Snyk
To help you get started, we've selected a few eel.init examples, ... return random.random() eel.start('sync_callbacks.html', block=False, size=(400, ...
Read more >
Python GUI Using Chrome - Nitratine
start(). If you want to execute code underneath eel.start() you can pass block=False as an argument to stop it from blocking. For ...
Read more >
Eel - Bountysource
Describe the bug. When the app is started with block=False, It gives the error as Error site can't be reached. Issue similar to...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found