PySimpleGUI / PySimpleGUI/PySimpleGUI

[ Bug] Some occasional exception - apparently handled, but then the webpage stops working

Open
#3,629 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
13.8k
Forks
1.8k
PR merge metrics
No merged PRs in 30d

Description

Type of Issues (Enhancement, Error, Bug, Question)

Bug

Operating System

Linux

Python version

3.7.8

PySimpleGUI Port and Version
<module 'PySimpleGUIWeb' from '/home/pi/.local/lib/python3.7/site-packages/PySimpleGUIWeb/__init__.py'>

>>> print(sg.version)     # PySimpleGUI version number
0.39.0  Released 6-Jun-2020

>>> print(sg.tclversion_detailed)   # tkinter detailed version number (in PySimpleGUI version 4.29.0+)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: module 'PySimpleGUIWeb' has no attribute 'tclversion_detailed'

>>> print(sg.sys.version) # Python version number
3.7.3 (default, Jul 25 2020, 13:03:44) 
[GCC 8.3.0]

Your Experience Levels In Months or Years

2_________ Python programming experience

30_________ Programming experience overall
no_________ Have used another Python GUI Framework (tkinter, Qt, etc) previously (yes/no is fine)?

You have completed these steps:
  • Read instructions on how to file an Issue
  • Searched through main docs http://www.PySimpleGUI.org for your problem
  • Searched through the readme for your specific port if not PySimpleGUI (Qt, WX, Remi)
  • Looked for Demo Programs that are similar to your goal http://www.PySimpleGUI.com
  • Note that there are also Demo Programs under each port on GitHub
  • Run your program outside of your debugger (from a command line)
  • Searched through Issues (open and closed) to see if already reported
  • Try again by upgrading your PySimpleGUI.py file to use the current one on GitHub. Your problem may have already been fixed but is not yet on PyPI.
Description of Problem / Question / Details

after some time, processing some button clicks (as simple as if pressed, increase an integer.)
this can spawn on the console as web page stops working:

----------------------------------------
Exception happened during processing of request from ('192.168.1.41', 58336)
Traceback (most recent call last):
  File "/usr/lib/python3.7/socketserver.py", line 650, in process_request_thread
    self.finish_request(request, client_address)
  File "/usr/lib/python3.7/socketserver.py", line 360, in finish_request
    self.RequestHandlerClass(request, client_address, self)
  File "/home/pi/.local/lib/python3.7/site-packages/PySimpleGUIWeb/PySimpleGUIWeb.py", line 3360, in __init__
    super(Window.MyApp, self).__init__(*args,  static_file_path={'C':'c:','c':'c:','D':'d:', 'd':'d:', 'E':'e:', 'e':'e:', 'dot':'.', '.':'.'})
  File "/home/pi/.local/lib/python3.7/site-packages/remi/server.py", line 313, in __init__
    super(App, self).__init__(request, client_address, server)
  File "/usr/lib/python3.7/socketserver.py", line 720, in __init__
    self.handle()
  File "/usr/lib/python3.7/http/server.py", line 426, in handle
    self.handle_one_request()
  File "/usr/lib/python3.7/http/server.py", line 414, in handle_one_request
    method()
  File "/home/pi/.local/lib/python3.7/site-packages/remi/server.py", line 566, in do_GET
    ws = WebSocketsHandler(self.headers, self.request, self.client_address, self.server)
  File "/home/pi/.local/lib/python3.7/site-packages/remi/server.py", line 129, in __init__
    socketserver.StreamRequestHandler.__init__(self, *args, **kwargs)
  File "/usr/lib/python3.7/socketserver.py", line 720, in __init__
    self.handle()
  File "/home/pi/.local/lib/python3.7/site-packages/remi/server.py", line 145, in handle
    clients[self.session].websockets.remove(self)
ValueError: list.remove(x): x not in list
----------------------------------------
Saved:  Normal
Saved:  Normal
----------------------------------------
Exception happened during processing of request from ('192.168.1.41', 58454)
Traceback (most recent call last):
  File "/usr/lib/python3.7/socketserver.py", line 650, in process_request_thread
    self.finish_request(request, client_address)
  File "/usr/lib/python3.7/socketserver.py", line 360, in finish_request
    self.RequestHandlerClass(request, client_address, self)
  File "/home/pi/.local/lib/python3.7/site-packages/PySimpleGUIWeb/PySimpleGUIWeb.py", line 3360, in __init__
    super(Window.MyApp, self).__init__(*args,  static_file_path={'C':'c:','c':'c:','D':'d:', 'd':'d:', 'E':'e:', 'e':'e:', 'dot':'.', '.':'.'})
  File "/home/pi/.local/lib/python3.7/site-packages/remi/server.py", line 313, in __init__
    super(App, self).__init__(request, client_address, server)
  File "/usr/lib/python3.7/socketserver.py", line 720, in __init__
    self.handle()
  File "/usr/lib/python3.7/http/server.py", line 426, in handle
    self.handle_one_request()
  File "/usr/lib/python3.7/http/server.py", line 394, in handle_one_request
    self.raw_requestline = self.rfile.readline(65537)
  File "/usr/lib/python3.7/socket.py", line 589, in readinto
    return self._sock.recv_into(b)
ConnectionResetError: [Errno 104] Connection reset by peer
----------------------------------------


Code To Duplicate

I cannot think of how to narrow it down, as I do not see any meaningful order of operatoin that causes this.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with PySimpleGUIWeb.py around line 3360 and the corresponding request handling in remi/server.py, especially websocket cleanup around line 145 and do_GET around line 566. Reproduce the intermittent list.remove and connection-reset failures if possible, then define a regression test that confirms the web page remains usable after the request error.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
frontend, web-dev
Issue type
Bug
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
20/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.