Force socket shutdown before close (#2607)

Co-authored-by: Zhiwei <zhi.wei.liang@outlook.com>
This commit is contained in:
Adam Hopkins 2022-11-29 12:04:22 +02:00 committed by GitHub
parent 4c14910d5b
commit aef2673c38
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -19,7 +19,7 @@ from importlib import import_module
from multiprocessing import Manager, Pipe, get_context from multiprocessing import Manager, Pipe, get_context
from multiprocessing.context import BaseContext from multiprocessing.context import BaseContext
from pathlib import Path from pathlib import Path
from socket import socket from socket import SHUT_RDWR, socket
from ssl import SSLContext from ssl import SSLContext
from typing import ( from typing import (
TYPE_CHECKING, TYPE_CHECKING,
@ -864,6 +864,7 @@ class StartupMixin(metaclass=SanicMeta):
sync_manager.shutdown() sync_manager.shutdown()
for sock in socks: for sock in socks:
sock.shutdown(SHUT_RDWR)
sock.close() sock.close()
socks = [] socks = []
trigger_events(main_stop, loop, primary) trigger_events(main_stop, loop, primary)