From 56660b868f8f680379b9ea98e261ce7a8b827a09 Mon Sep 17 00:00:00 2001 From: Rongrong Date: Tue, 7 Nov 2023 03:06:08 +0800 Subject: [PATCH] perf(compat): reuse SSLContext as aiohttp does Signed-off-by: Rongrong --- src/compat.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/compat.py b/src/compat.py index 9f60a25755..025f5d4d8d 100644 --- a/src/compat.py +++ b/src/compat.py @@ -94,6 +94,9 @@ async def __aexit__(self, exc_type, exc_value, traceback): ) +# Reuse SSLContext as aiohttp does: +# https://github.com/aio-libs/aiohttp/blob/b51610b93b2ae15c4062e3a1680a536ba5f4c5c4/aiohttp/connector.py#L906 +@functools.lru_cache(None) def ssl_create_default_context(): """`ssl.create_default_context`""" context = ssl.create_default_context()