From 21bcfbce1d9de7df3afb5ef52b1486260899318d Mon Sep 17 00:00:00 2001 From: dingbo Date: Mon, 11 Jul 2022 19:42:02 +0800 Subject: [PATCH] docs: test --- docs/examples/python/highvolume_example.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/docs/examples/python/highvolume_example.py b/docs/examples/python/highvolume_example.py index 00d5935965..8c964395a4 100644 --- a/docs/examples/python/highvolume_example.py +++ b/docs/examples/python/highvolume_example.py @@ -182,14 +182,16 @@ class SQLWriter: def run_read_task(task_id: int, task_queues: List[Queue]): table_count_per_task = TABLE_COUNT // READ_TASK_COUNT data_source = MockDataSource(f"tb{task_id}", table_count_per_task) - for table_id, line in data_source: - i = table_id % len(task_queues) - task_queues[i].put(line, block=True) + try: + for table_id, line in data_source: + i = table_id % len(task_queues) + task_queues[i].put(line, block=True) + except KeyboardInterrupt: + pass # ANCHOR_END: read - # ANCHOR: write def run_write_task(task_id: int, queue: Queue): log = logging.getLogger(f"WriteTask-{task_id}") @@ -204,6 +206,8 @@ def run_write_task(task_id: int, queue: Queue): writer.flush() else: time.sleep(0.01) + except KeyboardInterrupt: + pass except BaseException as e: msg = f"line={line}, buffer_count={writer.buffered_count}" log.debug(msg) -- GitLab