Skip to content

Commit

Permalink
Merge d6b0c5d into 2d99573
Browse files Browse the repository at this point in the history
  • Loading branch information
Ashley authored Sep 26, 2018
2 parents 2d99573 + d6b0c5d commit 61d8f06
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions black.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import asyncio
from asyncio.base_events import BaseEventLoop
from concurrent.futures import Executor, ProcessPoolExecutor
from concurrent.futures import Executor, ProcessPoolExecutor, ThreadPoolExecutor
from datetime import datetime
from enum import Enum, Flag
from functools import lru_cache, partial, wraps
Expand Down Expand Up @@ -340,7 +340,13 @@ def main(
)
else:
loop = asyncio.get_event_loop()
executor = ProcessPoolExecutor(max_workers=os.cpu_count())

cpu_count = os.cpu_count()
try:
executor = ProcessPoolExecutor(max_workers=cpu_count)
except ImportError:
executor = ThreadPoolExecutor(max_workers=cpu_count)

try:
loop.run_until_complete(
schedule_formatting(
Expand Down

0 comments on commit 61d8f06

Please sign in to comment.