Skip to content

Fix event loop issue and support multi-client#45

Open
WordlessMeteor wants to merge 4 commits intosousa-andre:masterfrom
WordlessMeteor:master
Open

Fix event loop issue and support multi-client#45
WordlessMeteor wants to merge 4 commits intosousa-andre:masterfrom
WordlessMeteor:master

Conversation

@WordlessMeteor
Copy link
Copy Markdown

@WordlessMeteor WordlessMeteor commented Oct 12, 2025

  1. (Commit: Fixed event loop issue) In Python 3.14, asyncio.events is changed: an event loop must be explicitly created before calling get_event_loop. The modified version has been proved running normally with Python 3.14 installed.
  2. (Commit: Multi-Client and No-Client Detection and Performance Optimization) Extended BaseConnector's application, so that to connect to only one process, it's up to user which League Client to build connection with.
  3. (Commit: Multi-Client and No-Client Detection and Performance Optimization) Optimized the running speed of _return_ux_process function, especially on Windows. Before this optimization, even if only one League Client is running, it still took about 5 seconds to connect to that client. After this optimization, with multiple League Clients running, it only takes about 1 second to show the entire process list. In the case where no League Client is running, the old Generator approach would cause the program stuck in the event loop, searching for any League Client that might be launched, but without given explicit prompt. Now, if no League Client is found, this library should give an explicit message and interrupt the program execution. Note that this condition can be reinforced to identifying the running League Client processes instead of only found processes, if this commit can be approved. You may check more details in the commit description.
  4. (Commit: Multi-Client Prompt Layout Optimization) Optimize display.
  5. (Commit: Enable Default Client Selection) QoL change.

Note:

  1. In a previous pull request, I imported pandas for process list print layout. Considering the code complexity and memory cost for building a pandas dataframe, this time I just implemented this table layout optimization by formatting the strings to be printed.
  2. To avoid zombie processes, a try-except statement takes the place of the previous method.
  3. I added type annotations to some code because I used a strict type annotation check strategy in my vscode editor and I want to decrease the number of issues as many as possible. In addition, some changed code have been annotated for easy understanding. If the code style doesn't fit yours, I can remove it in a subsequent commit.
  4. These type annotations require Python version ≥ 3.9. If you don't like this compatability loss, I can return to importing the "typing" library.

Adapted BaseConnector's event loop to Python 3.14.0 asyncio library.
1. Adapted `utils._return_ux_process` function, so that a list of processes, instead of only one process, are returned.
Discussion:
By a generator returned, the memory used is supposed to be significantly reduced, but in this case, since a user normally won't run multiple League Clients on one device, the memory cost difference between returning a generator and returning a list of processes shouldn't be too much.
2. Discuss about the number of running League Clients (namely the number of LeagueClientx.exe) through `connector.chooseClient` function.
(1) If no client is found, raise a new error `NoLeagueClientDetected`;
(2) if one client is found, build connection with that process;
(3) otherwise, display the process list and let the user decide which client process to build connection with.
While I was rewriting `utils._return_ux_process` function, two optimizations were made.
1. Optimized the running time of `_return_ux_process` funtion.
(1) Avoiding a zombie process by always checking a process' `status` method significantly increases the time expense. Therefore, A try-except statement is used to handle exceptions triggered by accessing the attribute of a zombie process.
(2) (Windows only) Accessing the cmdline attribute of a process significantly increases the time expense. Since LeagueClientUx.exe always has the correct name on Windows, there's no need to access a process' cmdline attribute on Windows.
2. Adjusted some type annotations. Note that these type annotations rely on Python ≥ 3.9.
@WordlessMeteor WordlessMeteor changed the title Compatability Improvement, Functional Update and Time Expense Optimization Fix event loop issue and support multi-client Oct 12, 2025
WordlessMeteor and others added 2 commits October 22, 2025 16:42
Optimized the prompt layout when multiple clients are detected.
By "+2", each pair of neighboring cells should be delimited by at least 2 spaces.
Now, when there's more than one League Client running and the library outputs multiple options to connect to, users may enter nothing, namely directly press Enter, to select the process with the latest creation time. To select another process, users still need to enter the process index shown in "No." column.
Besides, adjusted some code based on the strict type checking mode: One variable should have only one type.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant