PR #4666 (client/server fixes) merged into devel

58 views
Skip to first unread message

Edward K. Ream

unread,
May 7, 2026, 4:35:20 AMMay 7
to leo-editor
Leo's "devel" branch now contains PR #4666. This PR fixes various issues with leoserver.py and leoclient.py.

I have tested the code only on Windows. Please continue your testing. Thanks!

Edward

Viktor Ransmayr

unread,
May 7, 2026, 10:26:19 AM (14 days ago) May 7
to leo-editor
Hello Edward,

Edward K. Ream schrieb am Donnerstag, 7. Mai 2026 um 10:35:20 UTC+2:
Leo's "devel" branch now contains PR #4666. This PR fixes various issues with leoserver.py and leoclient.py.

I have tested the code only on Windows. Please continue your testing. Thanks!

On Debian 13 'leoclient' is working fine, when 'leoserver' is already started. 

After 'leoclient' is finished, 'leoserver' is shut down - and - reports the following errors:

###

    Ctrl+c to break
    server: User Connected, Total: 1, Limit: 1
    server: Error: id:    1                                   !error {} error called
    server: Error: id:   19                            !finishCreate {} _do_message: no response: 'finishCreate'
    server: Error: id:   48                !goto_line_in_leo_outline {} goto_line_in_leo_outline: no filePath given
    server: Error: id:   49                          !goto_nav_entry {} onSelectItem: no target found for None
    server: Error: id:   50                             !goto_script {} goto_script: no button index given
    server: Error: id:   53                        !insert_file_node {} insert_file_node: No filePath given
    server: Error: id:   66                     !paste_as_clone_node {} paste_as_clone_node: no string given
    server: Error: id:   67                       !paste_as_template {} paste_as_template: no string given
    server: Error: id:   68                              !paste_node {} paste_node: no string given
    server: Error: id:   72                              !remove_tag {} remove_tag: no tag
    server: Error: id:   83                                !tag_node {} tag_node: no tag
    server: Error: id:   99                    !get_all_leo_commands {} _check_c: no open commander
    server connection finished.  Total: 0, Limit: 1
    Shutting down leoserver
    leoserver: cancelled
    Checking for changed commanders...
    Stopped leobridge server
    📦[user@leo-on-debian leo-editor]$

###

I don't know, if those server errors are relevant ...

If 'leoserver' is not started manually before, 'leoclient' still crashes on Debian:

###

    📦[user@leo-on-debian leo-editor]$
    📦[user@leo-on-debian leo-editor]$ python3 -m leo.core.leoclient
    Traceback (most recent call last):
      File "<frozen runpy>", line 198, in _run_module_as_main
      File "<frozen runpy>", line 88, in _run_code
      File "/home/user/distroboxes/projects/leo-on-debian/leo-editor/leo/core/leoclient.py", line 266, in <module>
        main()
        ~~~~^^
      File "/home/user/distroboxes/projects/leo-on-debian/leo-editor/leo/core/leoclient.py", line 253, in main
        asyncio.run(client_main_loop(timeout))  # #4664
        ~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/usr/local/lib/python3.14/asyncio/runners.py", line 204, in run
        return runner.run(main)
               ~~~~~~~~~~^^^^^^
      File "/usr/local/lib/python3.14/asyncio/runners.py", line 127, in run
        return self._loop.run_until_complete(task)
               ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^
      File "/usr/local/lib/python3.14/asyncio/base_events.py", line 719, in run_until_complete
        return future.result()
               ~~~~~~~~~~~~~^^
      File "/home/user/distroboxes/projects/leo-on-debian/leo-editor/leo/core/leoclient.py", line 178, in client_main_loop
        async with websockets.connect(uri) as websocket:
                   ~~~~~~~~~~~~~~~~~~^^^^^
      File "/home/user/distroboxes/projects/leo-on-debian/.local/lib/python3.14/site-packages/websockets/asyncio/client.py", line 590, in __aenter__
        return await self
               ^^^^^^^^^^
      File "/home/user/distroboxes/projects/leo-on-debian/.local/lib/python3.14/site-packages/websockets/asyncio/client.py", line 544, in __await_impl__
        self.connection = await self.create_connection()
                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/home/user/distroboxes/projects/leo-on-debian/.local/lib/python3.14/site-packages/websockets/asyncio/client.py", line 470, in create_connection
        _, connection = await loop.create_connection(factory, **kwargs)
                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/usr/local/lib/python3.14/asyncio/base_events.py", line 1176, in create_connection
        raise OSError('Multiple exceptions: {}'.format(
            ', '.join(str(exc) for exc in exceptions)))
    OSError: Multiple exceptions: [Errno 111] Connect call failed ('::1', 32125, 0, 0), [Errno 111] Connect call failed ('127.0.0.1', 32125)
    📦[user@leo-on-debian leo-editor]$

###

With kind regards,

Viktor

Edward K. Ream

unread,
May 7, 2026, 11:11:24 AM (14 days ago) May 7
to leo-e...@googlegroups.com
On Thu, May 7, 2026 at 9:26 AM Viktor Ransmayr wrote:

> On Debian 13 'leoclient' is working fine, when 'leoserver' is already started.

Excellent.

> After 'leoclient' is finished, 'leoserver' is shut down - and - reports the following errors:

Those errors are expected. I get the same.

> If 'leoserver' is not started manually before, 'leoclient' still crashes on Debian:

>     OSError: Multiple exceptions: [Errno 111] Connect call failed ('::1', 32125, 0, 0), [Errno 111] Connect call failed ('127.0.0.1', 32125)

Thanks for this report. Please add the following to the end of function: main (leoclient.py):

    except OSError:
        print(f"{tag}: No server running")
    except Exception as e:
        print(f"{tag}: Unexpected exception: {e}")

Does that help? If so, I'll push the new code to "devel".

Edward






Viktor Ransmayr

unread,
May 7, 2026, 12:29:43 PM (14 days ago) May 7
to leo-editor
Hello Edward,

Edward K. Ream schrieb am Donnerstag, 7. Mai 2026 um 17:11:24 UTC+2:
...
Thanks for this report. Please add the following to the end of function: main (leoclient.py):

    except OSError:
        print(f"{tag}: No server running")
    except Exception as e:
        print(f"{tag}: Unexpected exception: {e}")

Does that help?

I did apply the changes you suggested. - See "Log-001" & "Log-002"

The message is a lot more precise - but - it is not resolved completely ... 

With kind regards,

Viktor

---

### <Log-001> ...

    [user@fedora-leo-study-vm leo-editor]$
    [user@fedora-leo-study-vm core]$ vi leoclient.py
    [user@fedora-leo-study-vm core]$
    [user@fedora-leo-study-vm core]$ cat leoclient.py | tail -20
    def main():
        try:
            asyncio.run(client_main_loop(timeout))  # #4664
        except KeyboardInterrupt:
            # This terminates the server abnormally.
            print(f"{tag}: Keyboard interrupt")
        except ConnectionRefusedError:

            print(f"{tag}: No server running")
        except asyncio.CancelledError:
            print(f"{tag}: Cancelled")

        except OSError:
            print(f"{tag}: No server running")
        except Exception as e:
            print(f"{tag}: Unexpected exception: {e}")

    # @-others

    if __name__ == '__main__':
        main()
    # @-leo

###

### <Log-002> ...

    [user@fedora-leo-study-vm core]$
    [user@fedora-leo-study-vm core]$ pwd
    /home/user/distroboxes/projects/leo-on-debian/leo-editor/leo/core
    [user@fedora-leo-study-vm core]$
    [user@fedora-leo-study-vm core]$ python3 -m leoclient

    Traceback (most recent call last):
      File "<frozen runpy>", line 198, in _run_module_as_main
      File "<frozen runpy>", line 88, in _run_code
      File "/home/user/distroboxes/projects/leo-on-debian/leo-editor/leo/core/leoclient.py", line 18, in <module>
        import websockets
    ModuleNotFoundError: No module named 'websockets'
    [user@fedora-leo-study-vm core]$

###

Edward K. Ream

unread,
May 7, 2026, 1:46:22 PM (14 days ago) May 7
to leo-e...@googlegroups.com
> I did apply the changes you suggested. - See "Log-001" & "Log-002"
> The message is a lot more precise - but - it is not resolved completely ...

Alright. I'll add the two statements.


>       File "/home/user/distroboxes/projects/leo-on-debian/leo-editor/leo/core/leoclient.py", line 18, in <module>
>         import websockets
>     ModuleNotFoundError: No module named 'websockets'

Why are you getting this message?? Leo's requirements (pyproject.toml and requirements.txt) include the websockets module.
Edward

Viktor Ransmayr

unread,
May 7, 2026, 2:27:59 PM (14 days ago) May 7
to leo-editor
Hello Edward,

I do not know :-(

I will investigate if my usage of 'containers / distrobox' has any side-effects ...

With kind regards,

Viktor
 

Viktor Ransmayr

unread,
May 8, 2026, 2:12:25 AM (13 days ago) May 8
to leo-editor
Hello Edward,

Viktor Ransmayr schrieb am Donnerstag, 7. Mai 2026 um 20:27:59 UTC+2:
Edward K. Ream schrieb am Donnerstag, 7. Mai 2026 um 19:46:22 UTC+2:
> I did apply the changes you suggested. - See "Log-001" & "Log-002"
> The message is a lot more precise - but - it is not resolved completely ...

Alright. I'll add the two statements.

>       File "/home/user/distroboxes/projects/leo-on-debian/leo-editor/leo/core/leoclient.py", line 18, in <module>
>         import websockets
>     ModuleNotFoundError: No module named 'websockets'

Why are you getting this message?? Leo's requirements (pyproject.toml and requirements.txt) include the websockets module.

I do not know :-(

I found the reason - and - it has nothing to do with my usage of containers ...

###

📦[user@leo-on-debian ~]$  
📦[user@leo-on-debian ~]$ cd leo-editor/
📦[user@leo-on-debian leo-editor]$  
📦[user@leo-on-debian leo-editor]$ python3 -m pip list | grep 'websockets'
websockets                    16.0
📦[user@leo-on-debian leo-editor]$  
📦[user@leo-on-debian leo-editor]$ python3 -m leo.core.leoclient
client: No server running
📦[user@leo-on-debian leo-editor]$  
📦[user@leo-on-debian leo-editor]$ cd leo/core
📦[user@leo-on-debian core]$  
📦[user@leo-on-debian core]$ python3 -m leoclient
Traceback (most recent call last):
 File "<frozen runpy>", line 198, in _run_module_as_main
 File "<frozen runpy>", line 88, in _run_code
 File "/home/user/distroboxes/projects/leo-on-debian/leo-editor/leo/core/leoclient.py", line 19, in
<module>
   from leo.core import leoGlobals as g
ModuleNotFoundError: No module named 'leo'
📦[user@leo-on-debian core]$

Edward K. Ream

unread,
May 8, 2026, 4:00:04 AM (13 days ago) May 8
to leo-e...@googlegroups.com
On Fri, May 8, 2026 at 1:12 AM Viktor Ransmayr wrote:

> I found the reason - and - it has nothing to do with my usage of containers ...

> [user@leo-on-debian core]$ python3 -m leoclient
> Traceback (most recent call last):
...
>  File ".../leo-on-debian/leo-editor/leo/core/leoclient.py", line 19, in

> <module>
>    from leo.core import leoGlobals as g
> ModuleNotFoundError: No module named 'leo'

I see. You should run leoclient.py from the leo-editor directory.

My leoclient.cmd file is:

@echo off
cls
cd c:\Repos\leo-editor
python -m leo.core.leoclient %*

HTH.

Edward
Reply all
Reply to author
Forward
0 new messages