Skip to content

Drop selector_loop module#1587

Merged
jason810496 merged 2 commits into
task-sdk/feature/coordinator-interfacefrom
task-sdk/feature/coordinator-interface-drop-selector-loop
May 20, 2026
Merged

Drop selector_loop module#1587
jason810496 merged 2 commits into
task-sdk/feature/coordinator-interfacefrom
task-sdk/feature/coordinator-interface-drop-selector-loop

Conversation

@jason810496

@jason810496 jason810496 commented May 20, 2026

Copy link
Copy Markdown
Member

What

As mentioned in apache#67175 (comment) comment, we should revert the changes of selector loop modularization as the new JavaCoordinator implementation does not need it at all.

The rewritten ``JavaCoordinator`` (``airflow.sdk.coordinators.java``) lets
the JVM connect directly to two listening sockets (``comm`` and ``logs``)
and uses the accepted sockets as the supervisor's ``stdin`` / log pipes
straight up. There is no bytes-bridge between two sockets, so
``make_raw_forwarder`` -- the only helper the extracted ``selector_loop``
module added beyond what was already inline in ``supervisor.py`` -- has
no caller.

``_JavaActivitySubprocess`` reuses ``_register_pipe_readers`` and
``_close_unused_sockets`` via subclassing ``ActivitySubprocess``; both
methods existed before the extraction and remain in ``supervisor.py``
after this revert. The inline selector dispatch loop and
``make_buffered_socket_reader`` come back into ``supervisor.py`` so the
existing call sites (including the ``triggerer_job_runner`` re-export)
keep working unchanged.

This reverts commit 56464a8 ("Add common
selector loop utilities for socket I/O handling for subprocesses") and
deletes ``test_selector_loop.py`` introduced by 4b80753.
@jason810496 jason810496 self-assigned this May 20, 2026
@jason810496 jason810496 requested a review from Copilot May 20, 2026 01:56
@jason810496 jason810496 changed the title Drop selector_loop module; new JavaCoordinator does not need it Drop selector_loop module May 20, 2026

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR reverts the previously introduced selector-loop modularization by removing the dedicated selector_loop module and folding the remaining needed logic back into the Task SDK supervisor, aligning with the newer JavaCoordinator direction.

Changes:

  • Deleted airflow.sdk.execution_time.selector_loop and its associated unit tests.
  • Inlined the selector event servicing logic into WatchedSubprocess._service_subprocess and moved make_buffered_socket_reader into supervisor.py.
  • Updated coordinator module docs to remove references to the removed selector loop module.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
task-sdk/tests/task_sdk/execution_time/test_selector_loop.py Removes selector-loop focused tests (needs replacement coverage for still-used buffering helper).
task-sdk/src/airflow/sdk/execution_time/supervisor.py Inlines selector loop behavior and re-homes make_buffered_socket_reader; adjusts typing/imports.
task-sdk/src/airflow/sdk/execution_time/selector_loop.py Deletes the selector-loop utility module entirely.
task-sdk/src/airflow/sdk/execution_time/coordinator.py Removes documentation references to selector_loop.service_selector.
Comments suppressed due to low confidence (1)

task-sdk/src/airflow/sdk/execution_time/supervisor.py:719

  • The return type annotation of _create_log_forwarder is incorrect: it returns the (handler, on_close) tuple from make_buffered_socket_reader(...), not a single Callable[[socket], bool]. This mismatch will confuse callers and type checkers; change the annotation back to the appropriate tuple/type alias (e.g. SelectorCallback).
    def _create_log_forwarder(self, loggers, name, log_level=logging.INFO) -> Callable[[socket], bool]:
        """Create a socket handler that forwards logs to a logger."""

Comment thread task-sdk/src/airflow/sdk/execution_time/supervisor.py
Comment thread task-sdk/src/airflow/sdk/execution_time/supervisor.py

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.

Comments suppressed due to low confidence (2)

task-sdk/src/airflow/sdk/execution_time/supervisor.py:932

  • The new inlined selector loop includes several “example”/narration comments that restate the code paths (EOF handling, BrokenPipeError behavior, etc.). These comments are likely to become stale and make the loop harder to scan; consider removing them or replacing them with a short summary of the callback contract.
            # Example of handler behavior:
            # If the subprocess writes "Hello, World!" to stdout:
            # - `socket_handler` reads and processes the message.
            # - If EOF is reached, the handler returns False to signal no more reads are expected.
            # - BrokenPipeError should be caught and treated as if the handler returned false, similar

task-sdk/src/airflow/sdk/execution_time/supervisor.py:2014

  • make_buffered_socket_reader was moved into supervisor.py while the dedicated selector-loop test module was removed. Since this function is still used for log/request sockets and has non-trivial buffering/EOF behavior, it should retain direct unit tests (e.g. relocate the previous tests to test_supervisor.py or a new focused test module that imports it from supervisor).
def make_buffered_socket_reader(
    gen: Generator[None, bytes | bytearray, None],
    on_close: Callable[[socket], None],
    buffer_size: int = 4096,
):

Comment thread task-sdk/src/airflow/sdk/execution_time/supervisor.py
Comment thread airflow-core/src/airflow/dag_processing/processor.py
@jason810496 jason810496 marked this pull request as ready for review May 20, 2026 03:30
@jason810496 jason810496 requested review from uranusjr and removed request for amoghrajesh, ashb, ephraimbuddy, jedcunningham and kaxil May 20, 2026 03:30

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 82e4dfe277

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread task-sdk/src/airflow/sdk/execution_time/selector_loop.py
@uranusjr

Copy link
Copy Markdown
Member

Is this a direct revert? (I’ll skip reviewing the details if it is.)

@jason810496

jason810496 commented May 20, 2026

Copy link
Copy Markdown
Member Author

Is this a direct revert? (I’ll skip reviewing the details if it is.)

It's necessary to manual revert instead of direct revert as we will encounter conflict for direct revert.
I had double checked myself for the revert change for this PR by comparing the diff between the target base.

@jason810496 jason810496 merged commit 5abb82e into task-sdk/feature/coordinator-interface May 20, 2026
4 checks passed
@jason810496 jason810496 deleted the task-sdk/feature/coordinator-interface-drop-selector-loop branch May 20, 2026 06:40
jason810496 added a commit that referenced this pull request May 22, 2026
* Drop selector_loop module; new JavaCoordinator does not need it

The rewritten ``JavaCoordinator`` (``airflow.sdk.coordinators.java``) lets
the JVM connect directly to two listening sockets (``comm`` and ``logs``)
and uses the accepted sockets as the supervisor's ``stdin`` / log pipes
straight up. There is no bytes-bridge between two sockets, so
``make_raw_forwarder`` -- the only helper the extracted ``selector_loop``
module added beyond what was already inline in ``supervisor.py`` -- has
no caller.

``_JavaActivitySubprocess`` reuses ``_register_pipe_readers`` and
``_close_unused_sockets`` via subclassing ``ActivitySubprocess``; both
methods existed before the extraction and remain in ``supervisor.py``
after this revert. The inline selector dispatch loop and
``make_buffered_socket_reader`` come back into ``supervisor.py`` so the
existing call sites (including the ``triggerer_job_runner`` re-export)
keep working unchanged.

This reverts commit 56464a8 ("Add common
selector loop utilities for socket I/O handling for subprocesses") and
deletes ``test_selector_loop.py`` introduced by 4b80753.

* Address copilot's comments
jason810496 added a commit that referenced this pull request May 23, 2026
* Drop selector_loop module; new JavaCoordinator does not need it

The rewritten ``JavaCoordinator`` (``airflow.sdk.coordinators.java``) lets
the JVM connect directly to two listening sockets (``comm`` and ``logs``)
and uses the accepted sockets as the supervisor's ``stdin`` / log pipes
straight up. There is no bytes-bridge between two sockets, so
``make_raw_forwarder`` -- the only helper the extracted ``selector_loop``
module added beyond what was already inline in ``supervisor.py`` -- has
no caller.

``_JavaActivitySubprocess`` reuses ``_register_pipe_readers`` and
``_close_unused_sockets`` via subclassing ``ActivitySubprocess``; both
methods existed before the extraction and remain in ``supervisor.py``
after this revert. The inline selector dispatch loop and
``make_buffered_socket_reader`` come back into ``supervisor.py`` so the
existing call sites (including the ``triggerer_job_runner`` re-export)
keep working unchanged.

This reverts commit 56464a8 ("Add common
selector loop utilities for socket I/O handling for subprocesses") and
deletes ``test_selector_loop.py`` introduced by 4b80753.

* Address copilot's comments
jason810496 added a commit that referenced this pull request May 23, 2026
* Drop selector_loop module; new JavaCoordinator does not need it

The rewritten ``JavaCoordinator`` (``airflow.sdk.coordinators.java``) lets
the JVM connect directly to two listening sockets (``comm`` and ``logs``)
and uses the accepted sockets as the supervisor's ``stdin`` / log pipes
straight up. There is no bytes-bridge between two sockets, so
``make_raw_forwarder`` -- the only helper the extracted ``selector_loop``
module added beyond what was already inline in ``supervisor.py`` -- has
no caller.

``_JavaActivitySubprocess`` reuses ``_register_pipe_readers`` and
``_close_unused_sockets`` via subclassing ``ActivitySubprocess``; both
methods existed before the extraction and remain in ``supervisor.py``
after this revert. The inline selector dispatch loop and
``make_buffered_socket_reader`` come back into ``supervisor.py`` so the
existing call sites (including the ``triggerer_job_runner`` re-export)
keep working unchanged.

This reverts commit 56464a8 ("Add common
selector loop utilities for socket I/O handling for subprocesses") and
deletes ``test_selector_loop.py`` introduced by 4b80753.

* Address copilot's comments
uranusjr pushed a commit that referenced this pull request May 25, 2026
* Drop selector_loop module; new JavaCoordinator does not need it

The rewritten ``JavaCoordinator`` (``airflow.sdk.coordinators.java``) lets
the JVM connect directly to two listening sockets (``comm`` and ``logs``)
and uses the accepted sockets as the supervisor's ``stdin`` / log pipes
straight up. There is no bytes-bridge between two sockets, so
``make_raw_forwarder`` -- the only helper the extracted ``selector_loop``
module added beyond what was already inline in ``supervisor.py`` -- has
no caller.

``_JavaActivitySubprocess`` reuses ``_register_pipe_readers`` and
``_close_unused_sockets`` via subclassing ``ActivitySubprocess``; both
methods existed before the extraction and remain in ``supervisor.py``
after this revert. The inline selector dispatch loop and
``make_buffered_socket_reader`` come back into ``supervisor.py`` so the
existing call sites (including the ``triggerer_job_runner`` re-export)
keep working unchanged.

This reverts commit 56464a8 ("Add common
selector loop utilities for socket I/O handling for subprocesses") and
deletes ``test_selector_loop.py`` introduced by 4b80753.

* Address copilot's comments
uranusjr pushed a commit that referenced this pull request May 26, 2026
* Drop selector_loop module; new JavaCoordinator does not need it

The rewritten ``JavaCoordinator`` (``airflow.sdk.coordinators.java``) lets
the JVM connect directly to two listening sockets (``comm`` and ``logs``)
and uses the accepted sockets as the supervisor's ``stdin`` / log pipes
straight up. There is no bytes-bridge between two sockets, so
``make_raw_forwarder`` -- the only helper the extracted ``selector_loop``
module added beyond what was already inline in ``supervisor.py`` -- has
no caller.

``_JavaActivitySubprocess`` reuses ``_register_pipe_readers`` and
``_close_unused_sockets`` via subclassing ``ActivitySubprocess``; both
methods existed before the extraction and remain in ``supervisor.py``
after this revert. The inline selector dispatch loop and
``make_buffered_socket_reader`` come back into ``supervisor.py`` so the
existing call sites (including the ``triggerer_job_runner`` re-export)
keep working unchanged.

This reverts commit 56464a8 ("Add common
selector loop utilities for socket I/O handling for subprocesses") and
deletes ``test_selector_loop.py`` introduced by 4b80753.

* Address copilot's comments
uranusjr pushed a commit that referenced this pull request May 26, 2026
* Drop selector_loop module; new JavaCoordinator does not need it

The rewritten ``JavaCoordinator`` (``airflow.sdk.coordinators.java``) lets
the JVM connect directly to two listening sockets (``comm`` and ``logs``)
and uses the accepted sockets as the supervisor's ``stdin`` / log pipes
straight up. There is no bytes-bridge between two sockets, so
``make_raw_forwarder`` -- the only helper the extracted ``selector_loop``
module added beyond what was already inline in ``supervisor.py`` -- has
no caller.

``_JavaActivitySubprocess`` reuses ``_register_pipe_readers`` and
``_close_unused_sockets`` via subclassing ``ActivitySubprocess``; both
methods existed before the extraction and remain in ``supervisor.py``
after this revert. The inline selector dispatch loop and
``make_buffered_socket_reader`` come back into ``supervisor.py`` so the
existing call sites (including the ``triggerer_job_runner`` re-export)
keep working unchanged.

This reverts commit 56464a8 ("Add common
selector loop utilities for socket I/O handling for subprocesses") and
deletes ``test_selector_loop.py`` introduced by 4b80753.

* Address copilot's comments
uranusjr pushed a commit that referenced this pull request May 26, 2026
* Drop selector_loop module; new JavaCoordinator does not need it

The rewritten ``JavaCoordinator`` (``airflow.sdk.coordinators.java``) lets
the JVM connect directly to two listening sockets (``comm`` and ``logs``)
and uses the accepted sockets as the supervisor's ``stdin`` / log pipes
straight up. There is no bytes-bridge between two sockets, so
``make_raw_forwarder`` -- the only helper the extracted ``selector_loop``
module added beyond what was already inline in ``supervisor.py`` -- has
no caller.

``_JavaActivitySubprocess`` reuses ``_register_pipe_readers`` and
``_close_unused_sockets`` via subclassing ``ActivitySubprocess``; both
methods existed before the extraction and remain in ``supervisor.py``
after this revert. The inline selector dispatch loop and
``make_buffered_socket_reader`` come back into ``supervisor.py`` so the
existing call sites (including the ``triggerer_job_runner`` re-export)
keep working unchanged.

This reverts commit 56464a8 ("Add common
selector loop utilities for socket I/O handling for subprocesses") and
deletes ``test_selector_loop.py`` introduced by 4b80753.

* Address copilot's comments
uranusjr pushed a commit that referenced this pull request May 27, 2026
* Drop selector_loop module; new JavaCoordinator does not need it

The rewritten ``JavaCoordinator`` (``airflow.sdk.coordinators.java``) lets
the JVM connect directly to two listening sockets (``comm`` and ``logs``)
and uses the accepted sockets as the supervisor's ``stdin`` / log pipes
straight up. There is no bytes-bridge between two sockets, so
``make_raw_forwarder`` -- the only helper the extracted ``selector_loop``
module added beyond what was already inline in ``supervisor.py`` -- has
no caller.

``_JavaActivitySubprocess`` reuses ``_register_pipe_readers`` and
``_close_unused_sockets`` via subclassing ``ActivitySubprocess``; both
methods existed before the extraction and remain in ``supervisor.py``
after this revert. The inline selector dispatch loop and
``make_buffered_socket_reader`` come back into ``supervisor.py`` so the
existing call sites (including the ``triggerer_job_runner`` re-export)
keep working unchanged.

This reverts commit 56464a8 ("Add common
selector loop utilities for socket I/O handling for subprocesses") and
deletes ``test_selector_loop.py`` introduced by 4b80753.

* Address copilot's comments
uranusjr pushed a commit that referenced this pull request May 27, 2026
* Drop selector_loop module; new JavaCoordinator does not need it

The rewritten ``JavaCoordinator`` (``airflow.sdk.coordinators.java``) lets
the JVM connect directly to two listening sockets (``comm`` and ``logs``)
and uses the accepted sockets as the supervisor's ``stdin`` / log pipes
straight up. There is no bytes-bridge between two sockets, so
``make_raw_forwarder`` -- the only helper the extracted ``selector_loop``
module added beyond what was already inline in ``supervisor.py`` -- has
no caller.

``_JavaActivitySubprocess`` reuses ``_register_pipe_readers`` and
``_close_unused_sockets`` via subclassing ``ActivitySubprocess``; both
methods existed before the extraction and remain in ``supervisor.py``
after this revert. The inline selector dispatch loop and
``make_buffered_socket_reader`` come back into ``supervisor.py`` so the
existing call sites (including the ``triggerer_job_runner`` re-export)
keep working unchanged.

This reverts commit 56464a8 ("Add common
selector loop utilities for socket I/O handling for subprocesses") and
deletes ``test_selector_loop.py`` introduced by 4b80753.

* Address copilot's comments
uranusjr pushed a commit that referenced this pull request May 27, 2026
* Drop selector_loop module; new JavaCoordinator does not need it

The rewritten ``JavaCoordinator`` (``airflow.sdk.coordinators.java``) lets
the JVM connect directly to two listening sockets (``comm`` and ``logs``)
and uses the accepted sockets as the supervisor's ``stdin`` / log pipes
straight up. There is no bytes-bridge between two sockets, so
``make_raw_forwarder`` -- the only helper the extracted ``selector_loop``
module added beyond what was already inline in ``supervisor.py`` -- has
no caller.

``_JavaActivitySubprocess`` reuses ``_register_pipe_readers`` and
``_close_unused_sockets`` via subclassing ``ActivitySubprocess``; both
methods existed before the extraction and remain in ``supervisor.py``
after this revert. The inline selector dispatch loop and
``make_buffered_socket_reader`` come back into ``supervisor.py`` so the
existing call sites (including the ``triggerer_job_runner`` re-export)
keep working unchanged.

This reverts commit 56464a8 ("Add common
selector loop utilities for socket I/O handling for subprocesses") and
deletes ``test_selector_loop.py`` introduced by 4b80753.

* Address copilot's comments
uranusjr pushed a commit that referenced this pull request May 27, 2026
* Drop selector_loop module; new JavaCoordinator does not need it

The rewritten ``JavaCoordinator`` (``airflow.sdk.coordinators.java``) lets
the JVM connect directly to two listening sockets (``comm`` and ``logs``)
and uses the accepted sockets as the supervisor's ``stdin`` / log pipes
straight up. There is no bytes-bridge between two sockets, so
``make_raw_forwarder`` -- the only helper the extracted ``selector_loop``
module added beyond what was already inline in ``supervisor.py`` -- has
no caller.

``_JavaActivitySubprocess`` reuses ``_register_pipe_readers`` and
``_close_unused_sockets`` via subclassing ``ActivitySubprocess``; both
methods existed before the extraction and remain in ``supervisor.py``
after this revert. The inline selector dispatch loop and
``make_buffered_socket_reader`` come back into ``supervisor.py`` so the
existing call sites (including the ``triggerer_job_runner`` re-export)
keep working unchanged.

This reverts commit 56464a8 ("Add common
selector loop utilities for socket I/O handling for subprocesses") and
deletes ``test_selector_loop.py`` introduced by 4b80753.

* Address copilot's comments
uranusjr pushed a commit that referenced this pull request May 27, 2026
* Drop selector_loop module; new JavaCoordinator does not need it

The rewritten ``JavaCoordinator`` (``airflow.sdk.coordinators.java``) lets
the JVM connect directly to two listening sockets (``comm`` and ``logs``)
and uses the accepted sockets as the supervisor's ``stdin`` / log pipes
straight up. There is no bytes-bridge between two sockets, so
``make_raw_forwarder`` -- the only helper the extracted ``selector_loop``
module added beyond what was already inline in ``supervisor.py`` -- has
no caller.

``_JavaActivitySubprocess`` reuses ``_register_pipe_readers`` and
``_close_unused_sockets`` via subclassing ``ActivitySubprocess``; both
methods existed before the extraction and remain in ``supervisor.py``
after this revert. The inline selector dispatch loop and
``make_buffered_socket_reader`` come back into ``supervisor.py`` so the
existing call sites (including the ``triggerer_job_runner`` re-export)
keep working unchanged.

This reverts commit 56464a8 ("Add common
selector loop utilities for socket I/O handling for subprocesses") and
deletes ``test_selector_loop.py`` introduced by 4b80753.

* Address copilot's comments
uranusjr pushed a commit that referenced this pull request May 27, 2026
* Drop selector_loop module; new JavaCoordinator does not need it

The rewritten ``JavaCoordinator`` (``airflow.sdk.coordinators.java``) lets
the JVM connect directly to two listening sockets (``comm`` and ``logs``)
and uses the accepted sockets as the supervisor's ``stdin`` / log pipes
straight up. There is no bytes-bridge between two sockets, so
``make_raw_forwarder`` -- the only helper the extracted ``selector_loop``
module added beyond what was already inline in ``supervisor.py`` -- has
no caller.

``_JavaActivitySubprocess`` reuses ``_register_pipe_readers`` and
``_close_unused_sockets`` via subclassing ``ActivitySubprocess``; both
methods existed before the extraction and remain in ``supervisor.py``
after this revert. The inline selector dispatch loop and
``make_buffered_socket_reader`` come back into ``supervisor.py`` so the
existing call sites (including the ``triggerer_job_runner`` re-export)
keep working unchanged.

This reverts commit 56464a8 ("Add common
selector loop utilities for socket I/O handling for subprocesses") and
deletes ``test_selector_loop.py`` introduced by 4b80753.

* Address copilot's comments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants