Tribler / tribler

Privacy enhanced BitTorrent client with P2P content discovery
https://www.tribler.org
GNU General Public License v3.0
4.8k stars 444 forks source link

A patch that fixes OSError "[WinError 64] The specified network name is no longer available" #7926

Closed kozlovsky closed 7 months ago

kozlovsky commented 7 months ago

This PR fixes #7759 by applying a monkey patch for the BaseProactorEventLoop._start_serving method on the win32 platform, as shown in https://github.com/python/cpython/issues/93821.

The accompanying tests cover the primary patched function that replaces BaseProactorEventLoop._start_serving, but the second function, IocpProactor.accept, is not covered as writing a full coverage test for it is a bit unpractical and unnecessary.

synctext commented 7 months ago

This is finally making progress on an issue first reported on by our users on 7 Oct 2021, but this can be a different uncaught OS Mac/Windows/Linux networking error! Both aiohttp and asyncio suffer.

Lessons for future: ASyncIO has issue with recv() and accept() with a patch from Jan 2020 (github.com/python/cpython/pull/18199#issue-555429288). Guido Himself is aware. We could switch to hipster FastAPI, but has reproducible the same issues (uvicorn server).

The select reactor has better support for networking errors, but requires meticious tracking of the 64 MAX handles. The proactor event handler supposes to have superior Windows support, but has uncaught OS errors (or fails to retry).