In src/black/concurrency.py, schedule_formatting() creates a multiprocessing.Manager() when write_back is DIFF or COLOR_DIFF, but the Manager is never explicitly shut down.
code location:
async def schedule_formatting(...):
lock = None
if write_back in (WriteBack.DIFF, WriteBack.COLOR_DIFF):
manager = Manager()
lock = manager.Lock()
Since Manager starts a separate server process, not calling shutdown() (or using a context manager) can lead to resource leaks when Black is used as a library or repeatedly in a long-running process. This is mostly hidden in CLI usage because the process exits immediately.
It would be safer to explicitly shut down the Manager or manage it via a context manager to match Python’s multiprocessing best practices.