-
Notifications
You must be signed in to change notification settings - Fork 220
Replace multiprocessing with ProcessPoolExecutor #1294
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
31a8c84
to
00ab3af
Compare
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.
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.
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.
Instead of relying on `multiprocessing.Pool`, this PR replaces the implementation of `parallel_exec_transform_with_prettyprint` with `concurrent.futures.ProcessPoolExecutor`
There was a problem hiding this 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.
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 |
Replace multiprocessing with ProcessPoolExecutor
Instead of relying on
multiprocessing.Pool
, this PR replaces the implementation ofparallel_exec_transform_with_prettyprint
withconcurrent.futures.ProcessPoolExecutor