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 closed
CURRENT 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.
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.
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 justin
AluConnector
class it will NOT work on multiple GUI button presses because the first loop is already dead.The error will be
CURRENT 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.
https://github.com/Aluerie/HextechButEfficient/blob/4e38e8a4ceab7c712b48efb54a60bdf3ef2b17d8/common/connector.py#L56-L57
LINKS
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.