Skip to content

Commit cf408e5

Browse files
Improved docs for TelnetServer.
1 parent 2a5fe53 commit cf408e5

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

src/prompt_toolkit/contrib/telnet/server.py

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,18 @@ async def _dummy_interact(connection: TelnetConnection) -> None:
266266
class TelnetServer:
267267
"""
268268
Telnet server implementation.
269+
270+
Example::
271+
272+
async def interact(connection):
273+
connection.send("Welcome")
274+
session = PromptSession()
275+
result = await session.prompt_async(message="Say something: ")
276+
connection.send(f"You said: {result}\n")
277+
278+
async def main():
279+
server = TelnetServer(interact=interact, port=2323)
280+
await server.run()
269281
"""
270282

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

341353
def start(self) -> None:
342354
"""
343-
Start the telnet server (stop by calling and awaiting `stop()`).
355+
Deprecated: Use `.run()` instead.
344356
345-
Note: When possible, it's better to call `.run()` instead.
357+
Start the telnet server (stop by calling and awaiting `stop()`).
346358
"""
347359
if self._run_task is not None:
348360
# Already running.
@@ -352,6 +364,8 @@ def start(self) -> None:
352364

353365
async def stop(self) -> None:
354366
"""
367+
Deprecated: Use `.run()` instead.
368+
355369
Stop a telnet server that was started using `.start()` and wait for the
356370
cancellation to complete.
357371
"""

0 commit comments

Comments
 (0)