MCPcopy Index your code
hub / github.com/masterking32/MasterHttpRelayVPN / _make_exception_handler

Function _make_exception_handler

main.py:315–331  ·  view source on GitHub ↗

Return an asyncio exception handler that silences Windows WinError 10054 noise from connection cleanup (ConnectionResetError in _ProactorBasePipeTransport._call_connection_lost), which is harmless but verbose on Python/Windows when a remote host force-closes a socket.

(log)

Source from the content-addressed store, hash-verified

313
314
315def _make_exception_handler(log):
316 """Return an asyncio exception handler that silences Windows WinError 10054
317 noise from connection cleanup (ConnectionResetError in
318 _ProactorBasePipeTransport._call_connection_lost), which is harmless but
319 verbose on Python/Windows when a remote host force-closes a socket."""
320 def handler(loop, context):
321 exc = context.get("exception")
322 cb = context.get("handle") or context.get("source_traceback", "")
323 if (
324 isinstance(exc, ConnectionResetError)
325 and "_call_connection_lost" in str(cb)
326 ):
327 return # suppress: benign Windows socket cleanup race
328 log.error("[asyncio] %s", context.get("message", context))
329 if exc:
330 loop.default_exception_handler(context)
331 return handler
332
333
334async def _run(config):

Callers 1

_runFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected