python-eel / Eel

A little Python library for making simple Electron-like HTML/JS GUI apps
MIT License
6.3k stars 580 forks source link

block=False gives me "ERR_CONNECTION_REFUSED" #595

Closed hasansezertasan closed 2 years ago

hasansezertasan commented 2 years ago

block=False gives me "ERR_CONNECTION_REFUSED" I want to call JS function from python but i get "ERR_CONNECTION_REFUSED" error whenever i use "block=False"

Python Backend

import eel

eel.init("web")  

@eel.expose    
def on_load():
    print("Application running")

eel.start(
    'index.html', 
    block=False,
    mode="chrome"
    )

while True:
    returned_value = input("Send message to frontend: ")
    eel.pythonMessage(returned_value)

JavaScript Part

function pythonMessage(message) {
  console.log(message);
}
eel.expose(pythonMessage);

Desktop (please complete the following information):

chrome_UOMikzIG5M 0

pythoniaweb commented 2 years ago

its a bug. idk how to fix it and its has been reported some days ago.

SuperZombi commented 2 years ago
eel.init(resource_path("web"))
eel.start("main.html", size=(600, 700))

The download takes a very long time, and at the end, a message appears in the browser console that the dsp resource could not be loaded.

image

Its trying to be loaded from this adress: http://conoret.com/dsp?h=localhost&r=0.28258187796006995

hasansezertasan commented 2 years ago

I figured it out!

The only difference is here...

import eel

eel.init("web")  

@eel.expose    
def on_load():
    print("Application running")

eel.start(
    'index.html', 
    block=False,
    mode="chrome"
    )

while True:
    eel.sleep(1) # I really don't know why this works but it works 💯 
    returned_value = input("Send message to frontend: ")
    eel.pythonMessage(returned_value)

I am glad that i find some sort of solution, can anyone has a proper answer why it doesn't work without sleep method and why works now?

SuperZombi commented 2 years ago

@vimevim

I am glad that i find some sort of solution, can anyone has a proper answer why it doesn't work without sleep method and why works now?

Its magic)

ghost commented 2 years ago

I figured it out!

The only difference is here...

import eel

eel.init("web")  

@eel.expose    
def on_load():
    print("Application running")

eel.start(
    'index.html', 
    block=False,
    mode="chrome"
    )

while True:
    eel.sleep(1) # I really don't know why this works but it works 💯 
    returned_value = input("Send message to frontend: ")
    eel.pythonMessage(returned_value)

I am glad that i find some sort of solution, can anyone has a proper answer why it doesn't work without sleep method and why works now?

Thank you so much! I didn't want to create a new thread and your solution works perfectly.

hasansezertasan commented 2 years ago

I figured it out! The only difference is here...

import eel

eel.init("web")  

@eel.expose    
def on_load():
    print("Application running")

eel.start(
    'index.html', 
    block=False,
    mode="chrome"
    )

while True:
    eel.sleep(1) # I really don't know why this works but it works 💯 
    returned_value = input("Send message to frontend: ")
    eel.pythonMessage(returned_value)

I am glad that i find some sort of solution, can anyone has a proper answer why it doesn't work without sleep method and why works now?

Thank you so much! I didn't want to create a new thread and your solution works perfectly.

You're welcome, I am happy to be helpful. 👋