Skip to content

Commit

Permalink
Set default asyncio loop to our explicitly created one + unset on exit
Browse files Browse the repository at this point in the history
  • Loading branch information
Cooper Ry Lees committed Jul 13, 2022
1 parent c68563b commit 082c98d
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/black/__init__.py
Expand Up @@ -788,6 +788,7 @@ def reformat_many(
executor = ThreadPoolExecutor(max_workers=1)

loop = asyncio.new_event_loop()
asyncio.set_event_loop(loop)
try:
loop.run_until_complete(
schedule_formatting(
Expand All @@ -801,7 +802,10 @@ def reformat_many(
)
)
finally:
shutdown(loop)
try:
shutdown(loop)
finally:
asyncio.set_event_loop(None)
if executor is not None:
executor.shutdown()

Expand Down

0 comments on commit 082c98d

Please sign in to comment.