diff --git a/python-packages/smithy-http/smithy_http/aio/crt.py b/python-packages/smithy-http/smithy_http/aio/crt.py index b064bab5..6cb635a4 100644 --- a/python-packages/smithy-http/smithy_http/aio/crt.py +++ b/python-packages/smithy-http/smithy_http/aio/crt.py @@ -5,6 +5,7 @@ import asyncio from collections.abc import AsyncGenerator, AsyncIterable, Awaitable from concurrent.futures import Future +from copy import deepcopy from io import BytesIO from threading import Lock from typing import TYPE_CHECKING, Any @@ -178,9 +179,7 @@ def __init__( client. """ _assert_crt() - self._config = ( - AWSCRTHTTPClientConfig() if client_config is None else client_config - ) + self._config = client_config or AWSCRTHTTPClientConfig() if eventloop is None: eventloop = _AWSCRTEventLoop() self._eventloop = eventloop @@ -334,3 +333,9 @@ async def _consume_body_async( dest.write(chunk) # Should we call close here? Or will that make the crt unable to read the last # chunk? + + def __deepcopy__(self, memo: Any) -> "AWSCRTHTTPClient": + return AWSCRTHTTPClient( + eventloop=self._eventloop, + client_config=deepcopy(self._config), + ) diff --git a/python-packages/smithy-http/tests/unit/aio/test_crt.py b/python-packages/smithy-http/tests/unit/aio/test_crt.py new file mode 100644 index 00000000..1afabc3d --- /dev/null +++ b/python-packages/smithy-http/tests/unit/aio/test_crt.py @@ -0,0 +1,8 @@ +from copy import deepcopy + +from smithy_http.aio.crt import AWSCRTHTTPClient + + +def test_deepcopy_client() -> None: + client = AWSCRTHTTPClient() + deepcopy(client)