Hi, The sample on this page is not demonstrating anything asynchronous: https://docs.python.org/3/library/asyncio.html Please make it into an example that actually makes sense in the context of the topic. For example - do something asynchronous (sleep 5 secs) while demonstrating that it is (e.g. make something else count to 10 in 1-second steps - so we can see what's going on). Also - the "Hello World" heading suggests it is script output, but it is not. Good idea to fix everything and be clear. Kind Regards, Chris Drake.
Hi Chris, On 5/2/20 3:33 PM, Chris Drake wrote:
The sample on this page is not demonstrating anything asynchronous: https://docs.python.org/3/library/asyncio.html
Thanks for your email. My position on this is that it should be kept short (as a Hello World should), it currently demonstrates the syntax (async and await), and the asyncio library (asyncio.run(), asyncio.sleep()), so it covers a wide range of the topic, which is dense and already a lot to digest without any explanation, for a a first timer. The shortest demo I typically give in my courses is: import asyncio async def tum(): while True: await asyncio.sleep(1) print("Tum") async def pak(): while True: await asyncio.sleep(1) print("Pak") asyncio.run(asyncio.wait({tum(), pak()})) but this already requires explanations and is probably too big for this "preview box": it would span down to the "Additionally, there are low-level APIs" paragraph (one paragraph below), and the asyncio.wait line is too long, it would be truncated horizontally so we'd have to split it in two or three lines, making it even longer. In the other hand, the 4 first links of the page are pointing to actual examples of asynchronicity. If you still think this need to be changed: please open an issue on bugs.python.org, and if possible provide examples that you think would fit. Bests, -- Julien Palard
Hi Julien, I filed a bug. Those links were too intimidating for any normal user to follow, and there’s no point keeping something "short" when it's pointless - it would be better to put nothing, than waste our time. I recommended this - an improvement of the doc from one of those links (it was important to reverse the hello and the world, so users know what's going on.) import asyncio import time async def say_after(delay, what): await asyncio.sleep(delay) print(what) async def main(): print(f"started at {time.strftime('%X')}") await say_after(2, 'world') await say_after(1, 'hello') print(f"finished at {time.strftime('%X')}") asyncio.run(main()) Kind Regards, Chris Drake Wednesday, May 6, 2020, 6:58:42 AM, Julien Palard wrote: JP> Hi Chris, JP> On 5/2/20 3:33 PM, Chris Drake wrote:
The sample on this page is not demonstrating anything asynchronous: https://docs.python.org/3/library/asyncio.html
JP> Thanks for your email. My position on this is that it should be kept JP> short (as a Hello World should), it currently demonstrates the syntax JP> (async and await), and the asyncio library (asyncio.run(), JP> asyncio.sleep()), so it covers a wide range of the topic, which is dense JP> and already a lot to digest without any explanation, for a a first timer. JP> The shortest demo I typically give in my courses is: JP> import asyncio JP> async def tum(): JP> while True: JP> await asyncio.sleep(1) JP> print("Tum") JP> async def pak(): JP> while True: JP> await asyncio.sleep(1) JP> print("Pak") JP> asyncio.run(asyncio.wait({tum(), pak()})) JP> but this already requires explanations and is probably too big for this JP> "preview box": it would span down to the "Additionally, there are JP> low-level APIs" paragraph (one paragraph below), and the asyncio.wait JP> line is too long, it would be truncated horizontally so we'd have to JP> split it in two or three lines, making it even longer. JP> In the other hand, the 4 first links of the page are pointing to actual JP> examples of asynchronicity. JP> If you still think this need to be changed: please open an issue on JP> bugs.python.org, and if possible provide examples that you think would fit. JP> Bests,
participants (2)
-
Chris Drake -
Julien Palard