-
Notifications
You must be signed in to change notification settings - Fork 1
Description
PROBLEM
If we want to use a single event loop over the whole execution then it won't be possible because lcu-driver library closes current event loop by default. Maybe, I don't understand something. But with just
def __init(self, ...):
super().__init__()
...in AluConnector class it will NOT work on multiple GUI button presses because the first loop is already dead.
The error will be
14:53:41 27/11 | INFO | connect | Icon with Id=25 was set correctly.
Exception in Tkinter callback
Traceback (most recent call last):
File "C:\Users\Me\AppData\Local\Programs\Python\Python311\Lib\tkinter\__init__.py", line 1948, in __call__
return self.func(*args)
^^^^^^^^^^^^^^^^
File "d:\LAPTOP\HextechButEfficient\venv\Lib\site-packages\customtkinter\windows\widgets\ctk_button.py", line 554, in _clicked
self._command()
File "D:\LAPTOP\HextechButEfficient\gui\elements.py", line 89, in update_console_box
connector.start()
File "d:\LAPTOP\HextechButEfficient\venv\Lib\site-packages\lcu_driver\connector.py", line 70, in start
wrapper()
File "d:\LAPTOP\HextechButEfficient\venv\Lib\site-packages\lcu_driver\connector.py", line 64, in wrapper
self.loop.run_until_complete(connection.init())
File "C:\Users\Me\AppData\Local\Programs\Python\Python311\Lib\asyncio\base_events.py", line 628, in run_until_complete
self._check_closed()
File "C:\Users\Me\AppData\Local\Programs\Python\Python311\Lib\asyncio\base_events.py", line 519, in _check_closed
raise RuntimeError('Event loop is closed')
RuntimeError: Event loop is closedCURRENT SOLUTION
One possible solution to this is to register a new loop on each GUI button press. But is it a good practice? I kinda doubt. If anybody knows better - please hit me up.
HextechButEfficient/common/connector.py
Lines 56 to 57 in 4e38e8a
| new_loop = asyncio.new_event_loop() | |
| super().__init__(loop=new_loop) |
LINKS
- connector.stop() issue sousa-andre/lcu-driver#18
- Fix bugs regarding connector.start() & connector.stop() sousa-andre/lcu-driver#34
Even tho these are about websocket issue, where the loop won't close (which is the opposite problem lol) because of oversight design; but still they might change the structure of event loops usage after solving those.