Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Only create httpx ssl context once #231

Merged
merged 6 commits into from
Sep 13, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/amcrest/http.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import logging
import re
import socket
import ssl
import threading
from contextlib import asynccontextmanager
from typing import AsyncIterator, Optional, Tuple, Union
Expand Down Expand Up @@ -46,6 +47,8 @@
except AttributeError:
pass

_DEFAULT_SSL_CONTEXT = ssl.create_default_context()

bdraco marked this conversation as resolved.
Show resolved Hide resolved
TimeoutT = Union[Optional[float], Tuple[Optional[float], Optional[float]]]
HttpxTimeoutT = Union[
Optional[float],
Expand Down Expand Up @@ -336,6 +339,7 @@ async def _async_command(
auth=self._async_token,
verify=self._verify,
timeout=httpx_timeout,
verify=_DEFAULT_SSL_CONTEXT,
bdraco marked this conversation as resolved.
Show resolved Hide resolved
) as client:
for loop in range(1, 2 + retries):
_LOGGER.debug(
Expand Down