diff options
author | Daniel Baumann <mail@daniel-baumann.ch> | 2023-12-17 10:46:40 +0000 |
---|---|---|
committer | Daniel Baumann <mail@daniel-baumann.ch> | 2023-12-17 10:46:40 +0000 |
commit | 4e61276ae3a4432a9d7a65dd49eb6ae71dd5f93a (patch) | |
tree | 57f9ac8ea7edafc3db4db312b8a369ab39711636 /examples/asyncio-ssh-python-embed.py | |
parent | Adding upstream version 3.0.23. (diff) | |
download | ptpython-upstream/3.0.25.tar.xz ptpython-upstream/3.0.25.zip |
Adding upstream version 3.0.25.upstream/3.0.25
Signed-off-by: Daniel Baumann <mail@daniel-baumann.ch>
Diffstat (limited to '')
-rwxr-xr-x | examples/asyncio-ssh-python-embed.py | 18 |
1 files changed, 6 insertions, 12 deletions
diff --git a/examples/asyncio-ssh-python-embed.py b/examples/asyncio-ssh-python-embed.py index 86b5607..be0689e 100755 --- a/examples/asyncio-ssh-python-embed.py +++ b/examples/asyncio-ssh-python-embed.py @@ -32,31 +32,25 @@ class MySSHServer(asyncssh.SSHServer): return ReplSSHServerSession(self.get_namespace) -def main(port=8222): +async def main(port: int = 8222) -> None: """ Example that starts the REPL through an SSH server. """ - loop = asyncio.get_event_loop() - # Namespace exposed in the REPL. environ = {"hello": "world"} # Start SSH server. - def create_server(): + def create_server() -> MySSHServer: return MySSHServer(lambda: environ) print("Listening on :%i" % port) print('To connect, do "ssh localhost -p %i"' % port) - loop.run_until_complete( - asyncssh.create_server( - create_server, "", port, server_host_keys=["/etc/ssh/ssh_host_dsa_key"] - ) + await asyncssh.create_server( + create_server, "", port, server_host_keys=["/etc/ssh/ssh_host_dsa_key"] ) - - # Run eventloop. - loop.run_forever() + await asyncio.Future() # Wait forever. if __name__ == "__main__": - main() + asyncio.run(main()) |