o
    i;                     @   s\   d dl Z d dlmZ d dlmZmZ d dlmZ d dlm	Z	 d dl
mZ G dd deZdS )	    N)Sequence)AnySupportsFloat)override)AsyncKeyValue)BaseWrapperc                       s  e Zd ZdZ	d!dededdf fddZedd	d
ededB de	ee
f dB fddZedd	dee dedB dee	ee
f dB  fddZedd	d
ededB dee	ee
f dB edB f fddZedd	dee dedB deee	ee
f dB edB f  fddZedddd
ede	ee
f dedB dedB ddf
ddZeddddee dee	ee
f  dedB deedB  dB ddf
ddZedd	d
ededB defddZedd	dee dedB defdd Z  ZS )"TimeoutWrappera5  Wrapper that adds timeout limits to all operations.

    This wrapper ensures that no operation takes longer than the specified timeout.
    If an operation exceeds the timeout, it raises asyncio.TimeoutError. This is useful
    for preventing operations from hanging indefinitely and for enforcing SLAs.
          @	key_valuetimeoutreturnNc                    s   || _ || _t   dS )zInitialize the timeout wrapper.

        Args:
            key_value: The store to wrap.
            timeout: Timeout in seconds for all operations. Defaults to 5.0 seconds.
        N)r
   r   super__init__)selfr
   r   	__class__ l/var/www/html/karishye-ai-python/venv/lib/python3.10/site-packages/key_value/aio/wrappers/timeout/wrapper.pyr      s   zTimeoutWrapper.__init__)
collectionkeyr   c                   $   t j| jj||d| jdI d H S N)r   r   r   )asynciowait_forr
   getr   r   r   r   r   r   r   r   #      "zTimeoutWrapper.getkeysc                   r   N)r   r   r   )r   r   r
   get_manyr   r   r   r   r   r   r   r    '   r   zTimeoutWrapper.get_manyc                   r   r   )r   r   r
   ttlr   r   r   r   r   r"   +   r   zTimeoutWrapper.ttlc                   r   r   )r   r   r
   ttl_manyr   r!   r   r   r   r#   /   r   zTimeoutWrapper.ttl_many)r   r"   valuer"   c                   (   t j| jj||||d| jdI d H S )N)r   r$   r   r"   r   )r   r   r
   putr   )r   r   r$   r   r"   r   r   r   r&   3   s   &zTimeoutWrapper.putvaluesc                   r%   )N)r   r'   r   r"   r   )r   r   r
   put_manyr   )r   r   r'   r   r"   r   r   r   r(   7   s   	zTimeoutWrapper.put_manyc                   r   r   )r   r   r
   deleter   r   r   r   r   r)   D   r   zTimeoutWrapper.deletec                   r   r   )r   r   r
   delete_manyr   r!   r   r   r   r*   H   r   zTimeoutWrapper.delete_many)r	   )__name__
__module____qualname____doc__r   floatr   r   strdictr   r   listr    tupler"   r#   r   r&   r   r(   boolr)   intr*   __classcell__r   r   r   r   r      sL    
.6:B8".r   )r   collections.abcr   typingr   r   typing_extensionsr   !key_value.aio.protocols.key_valuer   key_value.aio.wrappers.baser   r   r   r   r   r   <module>   s    