From dc5d6b8f3d590fc6da7b16a55cff27441b34e46c Mon Sep 17 00:00:00 2001 From: Zhenyu-Yuan <39400483+Zhenyu-Yuan@users.noreply.github.com> Date: Sat, 12 Dec 2020 17:42:52 +0800 Subject: [PATCH] Update spinner_asyncio.py After that, I can see the rotation in Pycharm. Otherwise, nothing will be seen before "Answer: 42" appear. By the way, the original edition gives what we expected in Jupyter. --- 18-asyncio-py3.7/spinner_asyncio.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/18-asyncio-py3.7/spinner_asyncio.py b/18-asyncio-py3.7/spinner_asyncio.py index 369a8f0..31bb014 100755 --- a/18-asyncio-py3.7/spinner_asyncio.py +++ b/18-asyncio-py3.7/spinner_asyncio.py @@ -14,7 +14,8 @@ async def spin(msg): # <1> for char in itertools.cycle('|/-\\'): status = char + ' ' + msg - print(status, flush=True, end='\r') + print(end='\r') + print(status, flush=True, end='') try: await asyncio.sleep(.1) # <2> except asyncio.CancelledError: # <3>