
    `f                     @    d dl Z d dlZd dlmZ d Zd Zd Zd Zd Z	dS )    N)asyncioc                     |dk    rdS t          | t                    r|                     d          } t          j        |           dz  }dt          |          z  }t          ||z            S )zn
    Maps the value to a node value between 0 and 4095
    using CRC, then down to one of the ring nodes.
       r   utf8i  i   )
isinstancestrencodebinasciicrc32floatint)value	ring_sizebigvalring_divisors       F/var/www/html/env/lib/python3.11/site-packages/channels_redis/utils.py_consistent_hashr      sn    
 A~~q% %V$$^E""U*F%	***Lv$%%%    c                 \     j          fd}t          j        |          _         d S )Nc                     j         v r<j                  }j         =                     |                                           | _         | j        |i |S )N)_layersrun_until_completeflushclose)selfargskwargslayerlooporiginal_implproxys       r   _wrapperz_wrap_close.<locals>._wrapper   s`    5=  M$'Ed###EKKMM222"
tz4*6***r   )r   types
MethodType)r!   r   r"   r    s   `` @r   _wrap_closer%      sI    JM+ + + + + + + !(D11DJJJr   c                    K   	 |                      d           d{V  dS # t          $ r  |                     d           d{V  Y dS w xY w)zF
    Handle compatibility with redis-py 4.x and 5.x close methods
    T)close_connection_poolN)acloseAttributeErrorr   )
connections    r   _close_redisr+   &   s      ;d;;;;;;;;;;; ; ; ;T::::::::::::;s   " &AAc                 ~   | sddigS t          | t          t          f          rt          d          g }| D ]}t          |t                    r|                    |           -t          |t          t          f          r%|                    |d         |d         d           n|                    d|i           |S )z
    Takes the value of the "hosts" argument and returns
    a list of kwargs to use for the Redis connection constructor.
    addresszredis://localhost:6379z?You must pass a list of Redis hosts, even if there is only one.r   r   )hostport)r   r   bytes
ValueErrordictappendtuplelist)hostsresultentrys      r   decode_hostsr9   0   s      74566%#u&& 
M
 
 	

 F . .eT"" 	.MM%    t}-- 	.MM58U1X>>????MM9e,----Mr   c                    |                                  } d| v r,|                     d          }t          j        j        |fi | S |                     dd          }|b|                     d          }|                     dd          }t          j        j        |t          j                            ||          fi | S t          j        di | S )z~
    Takes the value of the "host" argument and returns a suited connection pool to
    the corresponding redis instance.
    r-   master_nameN	sentinelssentinel_kwargs)r=    )copypopaioredisConnectionPoolfrom_urlsentinelSentinelConnectionPoolSentinel)r.   r-   r;   r<   r=   s        r   create_poolrG   J   s     99;;DD((9%%&/@@4@@@((=$//KHH[))	((#4d;; 7&&y/&RR
 
 
 
 	
 "**T***r   )
r
   r#   redisr   rA   r   r%   r+   r9   rG   r>   r   r   <module>rI      s~      % % % % % %& & & 2 2 2; ; ;  4+ + + + +r   