Skip to content

Conversation

zsol
Copy link
Contributor

@zsol zsol commented Feb 22, 2025

Replace multiprocessing with ProcessPoolExecutor

Instead of relying on multiprocessing.Pool, this PR replaces the implementation of parallel_exec_transform_with_prettyprint with concurrent.futures.ProcessPoolExecutor

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Feb 22, 2025
@zsol zsol force-pushed the pr1294 branch 2 times, most recently from 31a8c84 to 00ab3af Compare February 22, 2025 19:43
zsol added a commit that referenced this pull request Feb 22, 2025
This PR:
1. marks the `libcst.native` module as free-threading-compatible
2. replaces the use of ProcessPoolExecutor with ThreadPoolExecutor if free-threaded CPython is detected at runtime

This depends on #1294 and #1289.
zsol added a commit that referenced this pull request Feb 22, 2025
This PR:
1. marks the `libcst.native` module as free-threading-compatible
2. replaces the use of ProcessPoolExecutor with ThreadPoolExecutor if free-threaded CPython is detected at runtime

This depends on #1294 and #1289.
zsol added a commit that referenced this pull request Mar 7, 2025
This PR:
1. marks the `libcst.native` module as free-threading-compatible
2. replaces the use of ProcessPoolExecutor with ThreadPoolExecutor if free-threaded CPython is detected at runtime

This depends on #1294 and #1289.
ngoldbaum pushed a commit to ngoldbaum/LibCST that referenced this pull request Apr 1, 2025
This PR:
1. marks the `libcst.native` module as free-threading-compatible
2. replaces the use of ProcessPoolExecutor with ThreadPoolExecutor if free-threaded CPython is detected at runtime

This depends on Instagram#1294 and Instagram#1289.
ngoldbaum pushed a commit to ngoldbaum/LibCST that referenced this pull request Apr 8, 2025
This PR:
1. marks the `libcst.native` module as free-threading-compatible
2. replaces the use of ProcessPoolExecutor with ThreadPoolExecutor if free-threaded CPython is detected at runtime

This depends on Instagram#1294 and Instagram#1289.
ngoldbaum pushed a commit to ngoldbaum/LibCST that referenced this pull request Apr 10, 2025
This PR:
1. marks the `libcst.native` module as free-threading-compatible
2. replaces the use of ProcessPoolExecutor with ThreadPoolExecutor if free-threaded CPython is detected at runtime

This depends on Instagram#1294 and Instagram#1289.
zsol added a commit that referenced this pull request May 20, 2025
This PR:
1. marks the `libcst.native` module as free-threading-compatible
2. replaces the use of ProcessPoolExecutor with ThreadPoolExecutor if free-threaded CPython is detected at runtime

This depends on #1294 and #1289.
Instead of relying on `multiprocessing.Pool`, this PR replaces the implementation of `parallel_exec_transform_with_prettyprint` with `concurrent.futures.ProcessPoolExecutor`
@zsol zsol marked this pull request as ready for review May 21, 2025 19:09
@zsol zsol assigned amyreese and unassigned amyreese May 21, 2025
@zsol zsol requested a review from amyreese May 21, 2025 20:02
Copy link
Contributor

@amyreese amyreese left a comment

Choose a reason for hiding this comment

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

Seems reasonable.

Do you think it would be worth dumping the custom "walk paths" and "run things on a executor" bits in favor of using trailrunner. This is what we use for usort/ufmt/fixit/etc, and it ensures consistent behavior across OS (ie, spawn-only, no fork on Linux), obeys gitignore, etc. The "dummy pool" stuff could just be a matter of passing ThreadPoolExecutor as the default executor if needed, but we could also add an optimization in trailrunner instead.

@zsol
Copy link
Contributor Author

zsol commented May 22, 2025

I don't know if it's worth the effort - I found it's really nice not to have any dependencies. On the other hand, this frontend piece could use a lot of rework to make it easier to bootstrap your own single purpose codemod tool

@zsol zsol merged commit d002c14 into main May 22, 2025
61 checks passed
zsol added a commit that referenced this pull request May 22, 2025
This PR:
1. marks the `libcst.native` module as free-threading-compatible
2. replaces the use of ProcessPoolExecutor with ThreadPoolExecutor if free-threaded CPython is detected at runtime

This depends on #1294 and #1289.
zsol added a commit that referenced this pull request May 22, 2025
This PR:
1. marks the `libcst.native` module as free-threading-compatible
2. replaces the use of ProcessPoolExecutor with ThreadPoolExecutor if free-threaded CPython is detected at runtime

This depends on #1294 and #1289.
zsol added a commit that referenced this pull request May 22, 2025
This PR:
1. marks the `libcst.native` module as free-threading-compatible
2. replaces the use of ProcessPoolExecutor with ThreadPoolExecutor if free-threaded CPython is detected at runtime

This depends on #1294 and #1289.
zsol added a commit that referenced this pull request May 22, 2025
This PR:
1. marks the `libcst.native` module as free-threading-compatible
2. replaces the use of ProcessPoolExecutor with ThreadPoolExecutor if free-threaded CPython is detected at runtime

This depends on #1294 and #1289.
zsol added a commit that referenced this pull request May 22, 2025
This PR:
1. marks the `libcst.native` module as free-threading-compatible
2. replaces the use of ProcessPoolExecutor with ThreadPoolExecutor if free-threaded CPython is detected at runtime

This depends on #1294 and #1289.
zsol added a commit that referenced this pull request May 22, 2025
This PR:
1. marks the `libcst.native` module as free-threading-compatible
2. replaces the use of ProcessPoolExecutor with ThreadPoolExecutor if free-threaded CPython is detected at runtime

This depends on #1294 and #1289.
zsol added a commit that referenced this pull request May 25, 2025
This PR:
1. marks the `libcst.native` module as free-threading-compatible
2. replaces the use of ProcessPoolExecutor with ThreadPoolExecutor if free-threaded CPython is detected at runtime

This depends on #1294 and #1289.
zsol added a commit that referenced this pull request May 25, 2025
This PR:
1. marks the `libcst.native` module as free-threading-compatible
2. replaces the use of ProcessPoolExecutor with ThreadPoolExecutor if free-threaded CPython is detected at runtime

This depends on #1294 and #1289.
zsol added a commit that referenced this pull request May 25, 2025
This PR:
1. marks the `libcst.native` module as free-threading-compatible
2. replaces the use of ProcessPoolExecutor with ThreadPoolExecutor if free-threaded CPython is detected at runtime

This depends on #1294 and #1289.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants