1212
1313
1414def run_async (coro ) -> concurrent .futures .Future :
15- """
16- Await a coroutine from a synchronous function/method.
17- """
15+ """Await a coroutine from a synchronous function/method."""
1816
1917 global _event_loop # noqa: PLW0603
2018
@@ -33,22 +31,21 @@ def run_async(coro) -> concurrent.futures.Future:
3331
3432
3533async def async_wait (duration : float ) -> float :
36- """
37- Example async function that is called from a synchronous cmd2 command
38- """
34+ """Example async function that is called from a synchronous cmd2 command"""
3935 await asyncio .sleep (duration )
4036 return duration
4137
4238
4339class AsyncCallExample (cmd2 .Cmd ):
44- """
45- A simple cmd2 application.
40+ """A simple cmd2 application.
41+
4642 Demonstrates how to run an async function from a cmd2 command.
4743 """
4844
4945 def do_async_wait (self , _ : str ) -> None :
50- """
51- Waits asynchronously. Example cmd2 command that calls an async function.
46+ """Waits asynchronously.
47+
48+ Example cmd2 command that calls an async function.
5249 """
5350
5451 waitable = run_async (async_wait (0.1 ))
@@ -59,16 +56,15 @@ def do_async_wait(self, _: str) -> None:
5956 return
6057
6158 def do_hello_world (self , _ : str ) -> None :
62- """
63- Prints a simple greeting. Just a typical (synchronous) cmd2 command
59+ """Prints a simple greeting.
60+
61+ Just a typical (synchronous) cmd2 command
6462 """
6563 self .poutput ('Hello World' )
6664
6765
6866def main () -> int :
69- """
70- Main entry point for the example.
71- """
67+ """Main entry point for the example."""
7268 app = AsyncCallExample ()
7369 app .set_window_title ("Call to an Async Function Test" )
7470 return app .cmdloop ()
0 commit comments