[Pkg-mpd-commits] [python-mpd] 53/91: asyncio: Extend example

Simon McVittie smcv at debian.org
Sat Feb 24 14:55:35 UTC 2018


This is an automated email from the git hooks/post-receive script.

smcv pushed a commit to branch debian/master
in repository python-mpd.

commit 12b4783b25a5d9c353943ecb8610d62dcde674e7
Author: chrysn <chrysn at fsfe.org>
Date:   Fri Apr 7 11:03:23 2017 +0200

    asyncio: Extend example
---
 examples/asyncio_example.py | 30 ++++++++++++++++++++++++++----
 1 file changed, 26 insertions(+), 4 deletions(-)

diff --git a/examples/asyncio_example.py b/examples/asyncio_example.py
index 39d985d..194d3cd 100644
--- a/examples/asyncio_example.py
+++ b/examples/asyncio_example.py
@@ -21,11 +21,33 @@ async def main():
     else:
         print("Status success:", status)
 
-    for x in await client.decoders():
-        print("sync decoder:", x)
+    print(list(await client.commands()))
 
-    async for x in client.decoders():
-        print("async decoder:", x)
+    import time
+    start = time.time()
+    for x in await client.listall():
+        print("sync:", x)
+        print("Time to first sync:", time.time() - start)
+        break
+
+    start = time.time()
+    async for x in client.listall():
+        print("async:", x)
+        print("Time to first async:", time.time() - start)
+        break
+
+    try:
+        await client.addid()
+    except Exception as e:
+        print("An erroneous command, as expected, raised:", e)
+
+    try:
+        async for x in client.plchangesposid():
+            print("Why does this work?")
+    except Exception as e:
+        print("An erroneous asynchronously looped command, as expected, raised:", e)
+
+    print("Idle result", list(await client.idle()))
 
 if __name__ == '__main__':
     asyncio.get_event_loop().run_until_complete(main())

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-mpd/python-mpd.git



More information about the Pkg-mpd-commits mailing list