Eel icon indicating copy to clipboard operation
Eel copied to clipboard

With block=False and reading from sys.stdin, localhost doens't connect

Open vshesh opened this issue 5 years ago • 5 comments

Eel version 0.14.0

Describe the bug Running eel in non blocking mode, then reading from sys.stdin in a loop causes a localhost failed to connect in chrome.

** what happens ** Screen Shot 2020-10-25 at 8 10 30 PM

To Reproduce Steps to reproduce the behavior:

  1. create some web folder with a dummy index.html file
<!doctype html>
<html>
<head></head>
<body>
    <div id="container">
        <svg id="drawing"></svg>
    </div>
    <script src="https://d3js.org/d3.v6.min.js"></script>
    <script type="text/javascript" src="/eel.js"></script>
    <script src="index.js"></script>
</body>
</html>
  1. put this in a python file
import eel
import sys

eel.init('web')
eel.start('index.html', block=False)

while True:
  for l in sys.stdin:
    eel.draw([['x', 1, random.random()*500, random.random()* 500]])
  1. put this in a js file
eel.expose(draw)
function draw(to_draw) {
  d3.select('svg#drawing').selectAll('text')
  .data(to_draw).attr('x', d => d[2]).attr('y', d => d[3]).text(d => d[0])
  .enter().append('text').attr('x', d => d[2]).attr('y', d => d[3]).text(d => d[0])
  .exit().remove()
}

Expected behavior App should open as normal and display results of drawing a random x every second.

Desktop (please complete the following information):

  • OS: [e.g. iOS] MacOS 10.13
  • Browser [e.g. chrome, safari] chrome 86

Additional context Doing something non sys.stdin related in the while True loop works just fine, like

while True: 
  eel.draw([['x', 1, random.random()*500, random.random()*500]])
  eel.sleep(0.2)

vshesh avatar Oct 26 '20 03:10 vshesh

I have the same issue. I guess when the io-related blocking happens, it prevents the server from running properly.

raysuhyunlee avatar Oct 21 '21 05:10 raysuhyunlee

I'm having the exact same problem. I'm using a simple hello world eel project. When adding block=False, eel can no longer connect. It's super frustrating.

eatsana avatar Oct 23 '21 20:10 eatsana

Same problem here, although I don't use io things

Xyndra avatar Jan 06 '22 10:01 Xyndra

Some issue here.

GabrielLins64 avatar Feb 16 '22 03:02 GabrielLins64

Same here. As a workaround you can launch eel in a thread

import threading
import eel

def start_gui():
	eel.init ('gui')
	eel.start ('index.html')

gui_thread = threading.Thread (target=start_gui)
gui_thread.daemon = True
gui_thread.start()

# do other stuff

flappix avatar Jun 29 '23 22:06 flappix