Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: prevent closed pipe errors on closing asyncio transport resources
The proactor pipe transports for subprocess won't be automatically closed, so "closed pipe" errors (pytest warnings) occur during garbage collection (upon `__del__`). This results in a bunch of pytest warnings whenever closing and freeing up fixture Nvim sessions. A solution is to close all the internal `_ProactorBasePipeTransport` objects later when closing the asyncio event loop. Also, `_ProactorBasePipeTransport.close()` does not close immediately, but rather works asynchronously; therefore the `__del__` finalizer still can throw if called by GC after the event loop is closed. One solution for properly closing the pipe transports is to await the graceful shutdown of these transports. Example CI output (the pytest warnings that are going to be fixed): ``` Exception ignored in: <function _ProactorBasePipeTransport.__del__ at 0x00000205288AD1C0> Traceback (most recent call last): File "C:\hostedtoolcache\windows\Python\3.11.5\x64\Lib\asyncio\proactor_events.py", line 116, in __del__ _warn(f"unclosed transport {self!r}", ResourceWarning, source=self) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\hostedtoolcache\windows\Python\3.11.5\x64\Lib\asyncio\proactor_events.py", line 80, in __repr__ info.append(f'fd={self._sock.fileno()}') ^^^^^^^^^^^^^^^^^^^ File "C:\hostedtoolcache\windows\Python\3.11.5\x64\Lib\asyncio\windows_utils.py", line 102, in fileno raise ValueError("I/O operation on closed pipe") ValueError: I/O operation on closed pipe Exception ignored in: <function _ProactorBasePipeTransport.__del__ at 0x00000205288AD1C0> Traceback (most recent call last): File "C:\hostedtoolcache\windows\Python\3.11.5\x64\Lib\asyncio\proactor_events.py", line 116, in __del__ File "C:\hostedtoolcache\windows\Python\3.11.5\x64\Lib\asyncio\proactor_events.py", line 80, in __repr__ File "C:\hostedtoolcache\windows\Python\3.11.5\x64\Lib\asyncio\windows_utils.py", line 102, in fileno ValueError: I/O operation on closed pipe ```
- Loading branch information