Skip to content

Use regex matching for modules that should always fork#1255

Open
Nihlus wants to merge 1 commit into
mitogen-hq:masterfrom
Nihlus:improve-module-forking
Open

Use regex matching for modules that should always fork#1255
Nihlus wants to merge 1 commit into
mitogen-hq:masterfrom
Nihlus:improve-module-forking

Conversation

@Nihlus

@Nihlus Nihlus commented Feb 28, 2025

Copy link
Copy Markdown
Contributor

The current logic used to match module names that should always fork has room for improvement. As exemplified by the recent addition of the FreeIPA modules, which was a rather long list, the ability to use patterns instead of exact string matches would improve readability and long-term maintainability of the mechanism.

This PR changes the module set into a set of regular expression strings and compiles them into a single joint regex that we then use to match against the module name.

@moreati

moreati commented Aug 16, 2025

Copy link
Copy Markdown
Member

Notes/random thoughts

  • Agree the long frozenset is ugly and too brittle
  • If we're changing the interface/meaning of the attribute ALWAYS_FORK_MODULES, then it's probably not worth keeping.
  • Perhaps hide implementation details behind a method like _module_requires_fork(self, modname)
  • Could it become runtime configurable? E.g. Ansible plugin option, environment variable

Sorry for the long wait to look at this. I plan to give it more attention in the next few weeks

@moreati

moreati commented Feb 7, 2026

Copy link
Copy Markdown
Member

Note to self: Possible inspiration for user configurable ALWAYS_FORK_MODULES through an environment variable python/cpython#138149

@Nihlus Nihlus force-pushed the improve-module-forking branch from 72f4dac to a4d9328 Compare June 5, 2026 10:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

DesignRequired Issues that cannot progress due to incomplete design feature Design and functional additions

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants