From 1ffb1db1ae46c5b2472e0aa89c2797559820ce90 Mon Sep 17 00:00:00 2001 From: Myracle Date: Thu, 22 Jan 2026 16:52:44 +0800 Subject: [PATCH] [FLINK-38812][API/Python] Add log to show whether PYFLINK_CYTHON_ENABLED is set --- flink-python/pyflink/fn_execution/__init__.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/flink-python/pyflink/fn_execution/__init__.py b/flink-python/pyflink/fn_execution/__init__.py index 5fe372ac04e8a..bd8211dd33829 100644 --- a/flink-python/pyflink/fn_execution/__init__.py +++ b/flink-python/pyflink/fn_execution/__init__.py @@ -16,10 +16,15 @@ # limitations under the License. ################################################################################ +import logging import os +_LOG = logging.getLogger(__name__) + if 'PYFLINK_CYTHON_ENABLED' in os.environ: PYFLINK_CYTHON_ENABLED = bool(os.environ['PYFLINK_CYTHON_ENABLED']) + if not PYFLINK_CYTHON_ENABLED: + _LOG.info("PYFLINK_CYTHON_ENABLED is set to False via environment variable.") else: PYFLINK_CYTHON_ENABLED = True @@ -31,8 +36,10 @@ # Check whether beam could be fast and force PyFlink to be slow if beam is slow try: from apache_beam.coders import stream # noqa # pylint: disable=unused-import -except: +except Exception as e: PYFLINK_CYTHON_ENABLED = False + _LOG.info("PYFLINK_CYTHON_ENABLED is set to False because of " + "apache_beam.coders.stream import error: %s", str(e)) # Check whether PyFlink could be fast @@ -44,5 +51,9 @@ # noqa # pylint: disable=unused-import from pyflink.fn_execution.table import window_aggregate_fast, aggregate_fast \ # noqa # pylint: disable=unused-import -except: +except Exception as e: PYFLINK_CYTHON_ENABLED = False + _LOG.info("PYFLINK_CYTHON_ENABLED is set to False because of " + "pyflink cython extensions import error: %s", str(e)) + +_LOG.info("PYFLINK_CYTHON_ENABLED: %s", PYFLINK_CYTHON_ENABLED)