U
    .e	                     @  sL   d Z ddlmZ ddlmZ ddlmZ ddlmZ dZ	G dd	 d	eZ
d
S )zAmazon SQS Connection.    )annotations)get_event_loop)AsyncAWSQueryConnection   )boto3)AsyncSQSConnectionc                      s>   e Zd ZdZd fdd	Zdd Zdd
dZdddZ  ZS )r   zAsync SQS Connection.r   Nc                   s@   t d krtdt j|f||d| |dp8t | _d S )Nzboto3 is not installed)Zregion_namedebughub)r   ImportErrorsuper__init__getr   r	   )selfsqs_connectionr   Zregionkwargs	__class__ I/tmp/pip-unpacked-wheel-48hrr5dg/kombu/asynchronous/aws/sqs/connection.pyr      s    zAsyncSQSConnection.__init__c                   s$    fdd} j ||||| dS )a  Makes an asynchronous request to an SQS API.

        Arguments:
        ---------
        api -- The name of the API, e.g. 'receive_message'.
        callback -- The callback to pass the response to when it is available.
        *args, **kwargs -- The arguments and keyword arguments to pass to the
            SQS API. Those are API dependent and can be found in the boto3
            documentation.
        c                   s&   t  j| }|||}|r"|| d S )N)getattrr   )apicallbackargsr   methodrespr   r   r   sqs_request'   s    
z:AsyncSQSConnection._async_sqs_request.<locals>.sqs_requestN)r	   Z	call_soon)r   r   r   r   r   r   r   r   r   _async_sqs_request   s    z%AsyncSQSConnection._async_sqs_requestr   ZApproximateReceiveCountc                 C  s*   ||||d}|r||d< | j d|f|S )N)QueueUrlZMaxNumberOfMessagesZMessageAttributeNamesZWaitTimeSecondsZVisibilityTimeoutreceive_messager   )r   	queue_urlZnumber_messagesZvisibility_timeout
attributesZwait_time_secondsr   r   r   r   r   r    0   s    z"AsyncSQSConnection.receive_messagec                 C  s   | j d|||dS )Ndelete_message)r   ZReceiptHandler!   )r   r"   Zreceipt_handler   r   r   r   r$   @   s    z!AsyncSQSConnection.delete_message)r   N)r   Nr   NN)N)	__name__
__module____qualname____doc__r   r   r    r$   __classcell__r   r   r   r   r      s          
r   N)r(   
__future__r   Zkombu.asynchronousr   Z!kombu.asynchronous.aws.connectionr   extr   __all__r   r   r   r   r   <module>   s   