Wrap loop.run_in_executor
up in asyncio.ensure_future
for reliable cross-platform berhavior. (#679)
Closes #494 Task completion should also remove the task from `pending`. Only replicates on some platforms. (eg. Can replicate on Python 3.7+, with either Windows or whatever default Linux distro Travis uses.)
This commit is contained in:
parent
4a953b7241
commit
e6ddb68c78
8
black.py
8
black.py
@ -526,12 +526,14 @@ async def schedule_formatting(
|
||||
manager = Manager()
|
||||
lock = manager.Lock()
|
||||
tasks = {
|
||||
loop.run_in_executor(
|
||||
executor, format_file_in_place, src, fast, mode, write_back, lock
|
||||
asyncio.ensure_future(
|
||||
loop.run_in_executor(
|
||||
executor, format_file_in_place, src, fast, mode, write_back, lock
|
||||
)
|
||||
): src
|
||||
for src in sorted(sources)
|
||||
}
|
||||
pending: Iterable[asyncio.Task] = tasks.keys()
|
||||
pending: Iterable[asyncio.Future] = tasks.keys()
|
||||
try:
|
||||
loop.add_signal_handler(signal.SIGINT, cancel, pending)
|
||||
loop.add_signal_handler(signal.SIGTERM, cancel, pending)
|
||||
|
Loading…
Reference in New Issue
Block a user