Python Subprocess: how/when do they close file?
问题 I wonder why subprocesses keep so many files open. I have an example in which some files seem to remain open forever (after the subprocess finishes and even after the program crashes). Consider the following code: import aiofiles import tempfile async def main(): return [await fds_test(i) for i in range(2000)] async def fds_test(index): print(f"Writing {index}") handle, temp_filename = tempfile.mkstemp(suffix='.dat', text=True) async with aiofiles.open(temp_filename, mode='w') as fp: await fp