Fix process pool fallback on Python 3.10 (GH-2631)

In Python 3.10 the exception generated by creating a process pool on
a Python build that doesn't support this is now `NotImplementedError`

Commit history before merge:

* Fix process pool fallback on Python 3.10
* Update CHANGES.md
* Update CHANGES.md

Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
This commit is contained in:
Matthew D. Scholefield 2021-11-20 11:25:30 -08:00 committed by GitHub
parent 9a73bb86db
commit 05954c0950
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 1 deletions

View File

@ -1,5 +1,11 @@
# Change Log # Change Log
## Unreleased
### _Black_
- Fixed Python 3.10 support on platforms without ProcessPoolExecutor (#2631)
## 21.11b1 ## 21.11b1
### _Black_ ### _Black_

View File

@ -687,7 +687,7 @@ def reformat_many(
worker_count = min(worker_count, 60) worker_count = min(worker_count, 60)
try: try:
executor = ProcessPoolExecutor(max_workers=worker_count) executor = ProcessPoolExecutor(max_workers=worker_count)
except (ImportError, OSError): except (ImportError, NotImplementedError, OSError):
# we arrive here if the underlying system does not support multi-processing # we arrive here if the underlying system does not support multi-processing
# like in AWS Lambda or Termux, in which case we gracefully fallback to # like in AWS Lambda or Termux, in which case we gracefully fallback to
# a ThreadPoolExecutor with just a single worker (more workers would not do us # a ThreadPoolExecutor with just a single worker (more workers would not do us