Skip to content

Conversation

@jason810496
Copy link
Member

related: #52860

Why

When using setproctitle we should skip MacOS ( darwin ) as special case, see benoitc/gunicorn#3021 for more detail.
When refactoring in #52860, I found there are duplicate code to handle setproctitle for MacOS and some usage of setproctitle don't handle the MacOS problem, which might lead to error.

What

  • Add a new setproctitle utility in the airflow.utils module to centralize handling of the macOS error, allowing us to avoid the issue from the beginning.
  • Add corresponding tests for it

@pierrejeambrun
Copy link
Member

Might need a second pair of eyes, but LGTM

kaxil
kaxil previously requested changes Jul 10, 2025
Copy link
Member

@kaxil kaxil left a comment

Choose a reason for hiding this comment

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

Yeah, like @amoghrajesh mentioned that this is duplicated purposely to not have dependency for it between Core, SDK & Providers

@jason810496
Copy link
Member Author

So I need to wait until the PR for code sharing of "core", "task-sdk" and "provider" described in Dev Mail: Code sharing between Airflow Core and Task SDK - how do we achieve it then keep on this right ?

@kaxil
Copy link
Member

kaxil commented Jul 10, 2025

So I need to wait until the PR for code sharing of "core", "task-sdk" and "provider" described in Dev Mail: Code sharing between Airflow Core and Task SDK - how do we achieve it then keep on this right ?

The code is too small IMO -- duplication is not always bad :) We can leave this as-is and close this PR

@jason810496
Copy link
Member Author

The code is too small IMO -- duplication is not always bad :) We can leave this as-is and close this PR

I see! I’ll remove this small new module as I was previously a bit stuck trying to avoid duplication.
However, instead of closing this PR, I’ll update it to fix some remaining setproctitle usages that aren’t properly handled on macOS (e.g. in the Celery executor, edge worker, etc.).

@jason810496 jason810496 changed the title Centralize setproctitle utility Fix setproctitle usage Jul 11, 2025
@jason810496 jason810496 marked this pull request as draft July 11, 2025 04:40
@jason810496 jason810496 force-pushed the refactor/centralize-setproctitle-utility branch from d918926 to 2a025af Compare July 14, 2025 02:34
@jason810496 jason810496 marked this pull request as ready for review July 14, 2025 09:57
@jason810496 jason810496 requested review from amoghrajesh and kaxil July 14, 2025 09:58
Copy link
Member

@pierrejeambrun pierrejeambrun left a comment

Choose a reason for hiding this comment

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

Just a suggestion, but maybe I missed something.

edit: Just saw other comments, code duplication it is. We can still leave that at the top of each file to avoid duplication within the same file. (which shouldn't bring any cross component dependencies)

@jason810496 jason810496 marked this pull request as draft July 16, 2025 11:00
@jason810496 jason810496 force-pushed the refactor/centralize-setproctitle-utility branch from 2a025af to 7c758fa Compare July 20, 2025 12:47
pierrejeambrun
pierrejeambrun previously approved these changes Jul 22, 2025
Copy link
Member

@pierrejeambrun pierrejeambrun left a comment

Choose a reason for hiding this comment

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

Looks good. I see the PR is on draft is there anything left you wanted to implement there

@jason810496 jason810496 marked this pull request as ready for review July 22, 2025 13:12
@jason810496
Copy link
Member Author

Looks good. I see the PR is on draft is there anything left you wanted to implement there

No, thanks for the reminder, I just want to make sure the CI is green before marking the PR as ready to review.

@jason810496 jason810496 force-pushed the refactor/centralize-setproctitle-utility branch from 7c758fa to 56af22a Compare July 23, 2025 10:58
@jason810496
Copy link
Member Author

Hi @kaxil, this PR still needs your approval to resolve the requested changes. Thanks!

@jason810496 jason810496 force-pushed the refactor/centralize-setproctitle-utility branch from 56af22a to b4786a2 Compare August 1, 2025 07:13
@jason810496
Copy link
Member Author

It seems that this PR still needs @kaxil's approval before it can be merged.
(Due to GitHub restrictions, if any reviewer has requested changes, the PR requires that specific person's approval to unblock and proceed with the merge.)

@ashb
Copy link
Member

ashb commented Aug 1, 2025

Other committers can dismiss reviews. I've just done that, and let me give it a re-review.

Copy link
Member

@pierrejeambrun pierrejeambrun left a comment

Choose a reason for hiding this comment

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

That looks good to me. I'll let @ashb give the final word on this as requested

Copy link
Member

@potiuk potiuk left a comment

Choose a reason for hiding this comment

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

That calls a little for a "shared" distribution to include that code rather than copy it over. But it'a little to small to do it now. But maybe eventually when we expand on our "shared" projects concept we could have a separate "executors base" code an we split out executors to separately installable distributions, we could make the code implemented once. Maybe worth leaving TODO for that ?

Just a suggestion - not a blocker at all.

@ashb
Copy link
Member

ashb commented Aug 14, 2025

@potiuk I see it differently, and I'd say this is one of the cases where not using a shared dist and duplicating the code is better for readability -- this sort of case is exactly what I had in mind when I wrote this https://github.com/apache/airflow/tree/main/shared#be-thoughtful-about-what-you-add-under-here

Be Thoughtful about what you add under here

Not every piece of code used in two distributions should be automatically placed in one of the shared libraries, and sometimes "just duplicate it" is the right approach to take. For example, if it's just a 5 or 10 line function and it's used in two places, it might be easier for future developers to understand if the function is in two places.

@ashb ashb merged commit 30cc87e into apache:main Aug 14, 2025
76 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants