Skip to content

Commit

Permalink
Improved docs for TelnetServer.
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathanslenders committed Feb 17, 2023
1 parent 2a5fe53 commit cf408e5
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions src/prompt_toolkit/contrib/telnet/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,18 @@ async def _dummy_interact(connection: TelnetConnection) -> None:
class TelnetServer:
"""
Telnet server implementation.
Example::
async def interact(connection):
connection.send("Welcome")
session = PromptSession()
result = await session.prompt_async(message="Say something: ")
connection.send(f"You said: {result}\n")
async def main():
server = TelnetServer(interact=interact, port=2323)
await server.run()
"""

def __init__(
Expand Down Expand Up @@ -340,9 +352,9 @@ async def run(self, ready_cb: Callable[[], None] | None = None) -> None:

def start(self) -> None:
"""
Start the telnet server (stop by calling and awaiting `stop()`).
Deprecated: Use `.run()` instead.
Note: When possible, it's better to call `.run()` instead.
Start the telnet server (stop by calling and awaiting `stop()`).
"""
if self._run_task is not None:
# Already running.
Expand All @@ -352,6 +364,8 @@ def start(self) -> None:

async def stop(self) -> None:
"""
Deprecated: Use `.run()` instead.
Stop a telnet server that was started using `.start()` and wait for the
cancellation to complete.
"""
Expand Down

0 comments on commit cf408e5

Please sign in to comment.