From d4900d06339cd2085663d133421f2dfbe7a2fe6e Mon Sep 17 00:00:00 2001 From: Adam Ji Date: Thu, 29 Feb 2024 10:42:12 +0800 Subject: [PATCH] docs: fix python tmq demo --- docs/en/08-client-libraries/07-python.mdx | 6 ++---- docs/zh/08-connector/30-python.mdx | 6 ++---- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/docs/en/08-client-libraries/07-python.mdx b/docs/en/08-client-libraries/07-python.mdx index 82b889e0d3..3110afcf10 100644 --- a/docs/en/08-client-libraries/07-python.mdx +++ b/docs/en/08-client-libraries/07-python.mdx @@ -902,16 +902,14 @@ while True: -The `poll` function is used to consume data in tmq. The parameter of the `poll` function is a value of type float representing the timeout in seconds. It returns a `Message` before timing out, or `None` on timing out. You have to handle error messages in response data. +The `poll` function is used to consume data in tmq. The parameter of the `poll` function is a value of type float representing the timeout in seconds. It returns a `Message` before timing out, or `None` on timing out. ```python while True: message = consumer.poll(1) if not message: continue - err = message.error() - if err is not None: - raise err + for block in message: for row in block: print(row) diff --git a/docs/zh/08-connector/30-python.mdx b/docs/zh/08-connector/30-python.mdx index 491566e4e3..71dc82316e 100644 --- a/docs/zh/08-connector/30-python.mdx +++ b/docs/zh/08-connector/30-python.mdx @@ -911,16 +911,14 @@ while True: -Consumer API 的 `poll` 方法用于消费数据,`poll` 方法接收一个 float 类型的超时时间,超时时间单位为秒(s),`poll` 方法在超时之前返回一条 Message 类型的数据或超时返回 `None`。消费者必须通过 Message 的 `error()` 方法校验返回数据的 error 信息。 +Consumer API 的 `poll` 方法用于消费数据,`poll` 方法接收一个 float 类型的超时时间,超时时间单位为秒(s),`poll` 方法在超时之前返回一条 Message 类型的数据或超时返回 `None`。 ```python while True: message = consumer.poll(1) if not message: continue - err = message.error() - if err is not None: - raise err + for block in message: for row in block: print(row)