11import contextlib
22import logging
33from collections .abc import AsyncGenerator , Awaitable , Callable , Generator
4- from datetime import datetime , timezone
54from typing import TYPE_CHECKING
65
76from aiobotocore .session import get_session
3029class SQSBroker (AsyncBroker ):
3130 """AWS SQS TaskIQ broker."""
3231
33- def __init__ ( # noqa: PLR0913
32+ def __init__ (
3433 self ,
3534 queue_name : str ,
3635 endpoint_url : str | None = None ,
@@ -39,7 +38,6 @@ def __init__( # noqa: PLR0913
3938 aws_secret_access_key : str | None = None ,
4039 wait_time_seconds : int = 0 ,
4140 max_number_of_messages : int = 1 ,
42- force_ecs_container_credentials : bool = False ,
4341 ) -> None :
4442 """Initialize the SQS broker.
4543
@@ -50,9 +48,6 @@ def __init__( # noqa: PLR0913
5048 :param aws_secret_access_key: The AWS secret access key.
5149 :param: wait_time_seconds: The wait time used for long polling.
5250 :param: max_number_of_messages: Size of batch to receive from the queue.
53- :param: force_ecs_container_credentials: This bypasses the normal order of operations for boto3 auth and
54- goes straight to using the ECS role creds from the metadata service. This can be useful in edge cases
55- where there are higher priority credentials you do not want to use for this service.
5651 """
5752 super ().__init__ ()
5853
@@ -83,9 +78,6 @@ def __init__( # noqa: PLR0913
8378 except ValueError as error :
8479 raise BrokerInitError (details = "Invalid default queue configuration." ) from error
8580
86- self ._force_ecs_container_credentials = force_ecs_container_credentials
87- self ._creds_expiration : datetime | None = None
88-
8981 @contextlib .contextmanager
9082 def _handle_exceptions (self ) -> Generator [None , None , None ]:
9183 """Handle exceptions raised by the SQS client."""
@@ -104,10 +96,6 @@ def _handle_exceptions(self) -> Generator[None, None, None]:
10496 else :
10597 raise BrokerInitError (details = code or "" ) from e
10698
107- @property
108- def _sqs_credentials_expired (self ) -> datetime | bool | None :
109- return self ._creds_expiration and self ._creds_expiration < datetime .now (tz = timezone .utc )
110-
11199 async def _get_sqs_client (self ) -> "SQSClient" :
112100 self ._client_context_creator = self ._session .create_client (
113101 "sqs" ,
0 commit comments