From a82b9b56d44ed37c587648685826ad56b9177533 Mon Sep 17 00:00:00 2001 From: Matthias Geier Date: Tue, 17 Sep 2019 20:12:20 +0200 Subject: DOC: Update examples --- examples/asyncio_generators.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'examples/asyncio_generators.py') diff --git a/examples/asyncio_generators.py b/examples/asyncio_generators.py index c1e7bc6..463a650 100755 --- a/examples/asyncio_generators.py +++ b/examples/asyncio_generators.py @@ -10,6 +10,7 @@ You need Python 3.7 or newer to run this. """ import asyncio import queue +import sys import numpy as np import sounddevice as sd @@ -36,7 +37,7 @@ async def stream_generator(blocksize, *, channels=1, dtype='float32', The output blocks are uninitialized and have to be filled with appropriate audio signals. - + """ assert blocksize != 0 q_in = asyncio.Queue() @@ -97,8 +98,11 @@ async def main(**kwargs): try: await audio_task except asyncio.CancelledError: - print('wire was cancelled') + print('\nwire was cancelled') if __name__ == "__main__": - asyncio.run(main(blocksize=1024)) + try: + asyncio.run(main(blocksize=1024)) + except KeyboardInterrupt: + sys.exit('\nInterrupted by user') -- cgit v1.2.3