Ë
    ìÏjZ»  ã                  ó¼  — d dl mZ d dlZd dlmZmZ d dlZd dlZd dlZd dl	m
Z
 d dlmZmZmZ d dlZd dlZddlmZ ddlmZ dd	lmZ dd
lmZ  ej,                  e«      Z G d„ dej2                  «      Z G d„ de«      Z G d„ dej:                  ed¬«      Z G d„ d«      Z G d„ d«      Z  G d„ d«      Z!dddddddddddejD                  ejF                  dœd„Z$y)é    )ÚannotationsN)Ú	AwaitableÚCallable)ÚTracebackType)ÚAnyÚOptionalÚTypeé   )Úcompat©Ú
connection)Ú
exceptions)Úprotocolc                  ó(   ‡ — e Zd ZdZˆ fd„Zd„ Zˆ xZS )Ú_PoolConnectionHolderQueuez>Prefer live connections, with LIFO ordering within each group.c                óä   •— t        t        | j                  «      dz
  dd«      D ]<  }| j                  |   j                  «       sŒ!| j                  j	                  |«      c S  t
        ‰| �  «       S ©Nr
   éÿÿÿÿ)ÚrangeÚlenÚ_queueÚis_connectedÚpopÚsuperÚ_get)ÚselfÚiÚ	__class__s     €úI/var/www/html/gaurav-v2/venv/lib/python3.12/site-packages/asyncpg/pool.pyr   z_PoolConnectionHolderQueue._get   sY   ø€ Ü”s˜4Ÿ;™;Ó'¨!Ñ+¨R°Ö4ˆAØ�{‰{˜1‰~×*Ñ*Õ,Ø—{‘{—‘ qÓ)Ò)ð 5ô ‰w‰|‹~Ðó    c                ó   — t        t        | j                  «      dz
  dd«      D ]Y  }| j                  |   j                  «       rŒ!| j                  j	                  |«      }| j                  | j                  «       |c S  t        j                  ‚r   )	r   r   r   r   r   Ú_wakeup_nextÚ_puttersÚasyncioÚ
QueueEmpty)r   r   Úholders      r   Úget_disconnected_nowaitz2_PoolConnectionHolderQueue.get_disconnected_nowait%   sn   € Ü”s˜4Ÿ;™;Ó'¨!Ñ+¨R°Ö4ˆAØ—;‘;˜q‘>×.Ñ.Õ0ØŸ™Ÿ™¨Ó+�Ø×!Ñ! $§-¡-Ô0Ø’ð	 5ô
 × Ñ Ð r    )Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r'   Ú__classcell__©r   s   @r   r   r      s   ø„ ÙHôö!r    r   c                  óV   ‡ — e Zd Zddœ	 	 	 	 	 	 	 	 	 dˆ fd„Ze	 	 	 	 	 	 dd„«       Zˆ xZS )ÚPoolConnectionProxyMetaF)Úwrapc               óº  •— |rÇt        t        j                  «      D ]Š  }|j                  d«      s||v rŒt	        t        j                  |«      }t        j                  |«      sŒIt        j                  |«      }| j                  ||«      }t        j                  ||«      }|||<   ŒŒ d|vrt        j                  j                  |d<   t        ‰	| �5  | |||«      S )NÚ_r+   )Údirr   Ú
ConnectionÚ
startswithÚgetattrÚinspectÚ
isfunctionÚiscoroutinefunctionÚ_wrap_connection_methodÚ	functoolsÚupdate_wrapperr+   r   Ú__new__)
ÚmclsÚnameÚbasesÚdctr0   ÚattrnameÚmethÚiscoroutineÚwrapperr   s
            €r   r=   zPoolConnectionProxyMeta.__new__0   sÈ   ø€ ñ Ü¤
× 5Ñ 5Ö6�Ø×&Ñ& sÔ+¨x¸3©Øäœz×4Ñ4°hÓ?�Ü×)Ñ)¨$Ô/Øä%×9Ñ9¸$Ó?�Ø×6Ñ6°xÀÓM�Ü#×2Ñ2°7¸DÓA�Ø '��H’ð 7ð  Ñ#Ü!+×!6Ñ!6×!>Ñ!>��I‘ä‰w‰˜t T¨5°#Ó6Ð6r    c                óB   ‡ — dˆ fd„}|rt        j                  |«       |S )Nc                óÐ   •— | j                   €$t        j                  dj                  ‰«      «      ‚t	        | j                   j
                  ‰«      } || j                   g|¢­i |¤ŽS )NzJcannot call Connection.{}(): connection has been released back to the pool)Ú_conr   ÚInterfaceErrorÚformatr6   r   )r   ÚargsÚkwargsrC   Ú	meth_names       €r   Úcall_con_methodzHPoolConnectionProxyMeta._wrap_connection_method.<locals>.call_con_methodO   se   ø€ à�y‰yÐ Ü ×/Ñ/ðDßDJÁFØ!óE#ó$ð $ô
 ˜4Ÿ9™9×.Ñ.°	Ó:ˆDÙ˜Ÿ	™	Ð3 DÒ3¨FÑ3Ð3r    )r   r   rK   r   rL   r   Úreturnr   )r   Úmarkcoroutinefunction)rM   rD   rN   s   `  r   r:   z/PoolConnectionProxyMeta._wrap_connection_methodK   s!   ø€ õ		4ñ Ü×(Ñ(¨Ô9àÐr    )
r?   Ústrr@   ztuple[Type[Any], ...]rA   zdict[str, Any]r0   ÚboolrO   r/   )rM   rQ   rD   rR   rO   zCallable[..., Any])r(   r)   r*   r=   Ústaticmethodr:   r,   r-   s   @r   r/   r/   .   si   ø„ ð ñ7àð7ð %ð7ð ð	7ð ð7ð 
!õ7ð6 ðØðØ%)ðà	òó ôr    r/   c                  ó<   — e Zd ZdZ	 	 	 	 	 	 dd„Zdd„Zd	d„Zd
d„Zy)ÚPoolConnectionProxy)rH   Ú_holderc                óB   — || _         || _        |j                  | «       y ©N)rH   rV   Ú
_set_proxy)r   r&   Úcons      r   Ú__init__zPoolConnectionProxy.__init__f   s   € ð ˆŒ	ØˆŒØ�‰�tÕr    c                ó.   — t        | j                  |«      S rX   )r6   rH   )r   Úattrs     r   Ú__getattr__zPoolConnectionProxy.__getattr__m   s   € ä�t—y‘y $Ó'Ð'r    c                ój   — | j                   €y | j                   d c}| _         |j                  d «       |S rX   )rH   rY   )r   rZ   s     r   Ú_detachzPoolConnectionProxy._detachq   s1   € Ø�9‰9ÐØàŸ™ DˆˆˆTŒYØ�‰�tÔØˆ
r    c                óð   — | j                   €0dj                  | j                  j                  t	        | «      ¬«      S dj                  | j                  j                  | j                   t	        | «      ¬«      S )Nz <{classname} [released] {id:#x}>)Ú	classnameÚidz<{classname} {con!r} {id:#x}>)rb   rZ   rc   )rH   rJ   r   r(   rc   ©r   s    r   Ú__repr__zPoolConnectionProxy.__repr__y   sn   € Ø�9‰9ÐØ5×<Ñ<ØŸ.™.×1Ñ1´b¸³hð =ó @ð @ð 3×9Ñ9ØŸ.™.×1Ñ1°t·y±yÄRÈÃXð :ó Oð Or    N)r&   ÚPoolConnectionHolderrZ   zconnection.ConnectionrO   ÚNone)r]   rQ   rO   r   )rO   zOptional[connection.Connection])rO   rQ   )r(   r)   r*   Ú	__slots__r[   r^   r`   re   © r    r   rU   rU   `   s6   „ ð $€IðØ*ðØ1Fðà	óó(óôOr    rU   T)Ú	metaclassr0   c                  ó”   — e Zd ZdZ	 	 	 	 	 	 	 	 	 	 dd„Zdd„Zdd„Zdd„Zdd„Zdd„Z	dd„Z
dd	„Zdd
„Zdd„Zdd„Zdd„Zdd„Zdd„Zy)rf   )rH   Ú_poolÚ_loopÚ_proxyÚ_max_queriesÚ_setupÚ_max_inactive_timeÚ_in_useÚ_inactive_callbackÚ_timeoutÚ_generationÚ__weakref__c               ó�   — || _         d | _        d | _        || _        || _        || _        d | _        d | _        d | _        d | _	        y rX   )
rl   rH   rn   ro   rq   rp   rs   rr   rt   ru   )r   ÚpoolÚmax_queriesÚsetupÚmax_inactive_times        r   r[   zPoolConnectionHolder.__init__Š   sN   € ð ˆŒ
Ø59ˆŒ	Ø59ˆŒà'ˆÔØ"3ˆÔØˆŒØ6:ˆÔØ15ˆŒØ)-ˆŒØ*.ˆÕr    c                óX   — | j                   d uxr | j                   j                  «        S rX   )rH   Ú	is_closedrd   s    r   r   z!PoolConnectionHolder.is_connectedŸ   s&   € Ø�y‰y Ð$ÒB¨T¯Y©Y×-@Ñ-@Ó-BÐ)BÐBr    c                ó   — | j                    S rX   ©rr   rd   s    r   Úis_idlezPoolConnectionHolder.is_idle¢   s   € Ø—<‘<ÐÐr    c              ƒ  ó.  K  — | j                   �t        j                  d«      ‚| j                  j                  }| j                  j                  «       ƒ d {  –—† }| j                  j                  «       r-|j                  «       ƒ d {  –—†  t        j                  d«      ‚|j                  «       rt        j                  d«      ‚|| _         t        j                  | «      |_        || _        | j                  «        | j                  «        y 7 Œ¹7 Œ‰­w)NzMPoolConnectionHolder.connect() called while another connection already existsúpool is closingz0connection was closed during pool initialization)rH   r   ÚInternalClientErrorrl   ru   Ú_get_new_connectionÚ
is_closingÚcloserI   r}   ÚConnectionDoesNotExistErrorÚweakrefÚrefÚ_pool_holderÚ_maybe_cancel_inactive_callbackÚ_setup_inactive_callback)r   Ú
generationrZ   s      r   ÚconnectzPoolConnectionHolder.connect¥   sá   è ø€ Ø�9‰9Ð Ü×0Ñ0ð,ó-ð -ð —Z‘Z×+Ñ+ˆ
Ø—J‘J×2Ñ2Ó4×4ˆØ�:‰:× Ñ Ô"Ø—)‘)“+×ÐÜ×+Ñ+Ð,=Ó>Ð>Ø�=‰=Œ?Ü×8Ñ8ØBóDð DàˆŒ	ä"Ÿ;™; tÓ,ˆÔØ%ˆÔØ×,Ñ,Ô.Ø×%Ñ%Õ'ð 5øàús%   ‚ADÁDÁ1DÂ	DÂ
BDÄDc              ƒ  óP  K  — | j                   �| j                   j                  «       r d | _         | j                  «       ƒ d {  –—†  n‹| j                  | j                  j                  k7  rh| j                  j
                  j                  | j                   j                  | j                  ¬«      «       d | _         | j                  «       ƒ d {  –—†  | j                  «        t        | | j                   «      x| _        }| j                  �	 | j                  |«      ƒ d {  –—†  | j                  j
                  j!                  «       | _        |S 7 �Œ7 Œ…7 Œ4# t        t        j                  f$ r1}	 | j                   j                  «       ƒ d {  –—†7   |‚# |‚xY wd }~ww xY w­w)N©Útimeout)rH   r}   rŽ   ru   rl   rm   Úcreate_taskr†   rt   r‹   rU   rn   rp   Ú	Exceptionr$   ÚCancelledErrorÚcreate_futurerr   )r   ÚproxyÚexs      r   ÚacquirezPoolConnectionHolder.acquireº   sG  è ø€ Ø�9‰9Ð §	¡	× 3Ñ 3Ô 5ØˆDŒIØ—,‘,“.× Ñ à×Ñ §¡×!7Ñ!7Ò7à�J‰J×Ñ×(Ñ(Ø—	‘	—‘¨¯©�Ó6ô8àˆDŒIØ—,‘,“.× Ð à×,Ñ,Ô.ä1°$¸¿	¹	ÓBÐBˆŒ�eà�;‰;Ð"ðØ—k‘k %Ó(×(Ð(ð —z‘z×'Ñ'×5Ñ5Ó7ˆŒàˆðA !ùð !øð )ùÜœw×5Ñ5Ð6ò ð
ð
 Ÿ)™)Ÿ/™/Ó+×+Ñ+à�Hø˜"�Hþðüsy   ‚AF&ÁEÁBF&ÃEÃ=F&ÄE Ä"EÄ#E Ä',F&ÅF&ÅE ÅF#Å3FÆFÆFÆFÆFÆFÆF#Æ#F&c              ƒ  óÆ  K  — | j                   €t        j                  d«      ‚| j                  j	                  «       r| j                  j                  «        y d | _        | j                  j                  j                  | j                  k\  r%| j                  j                  |¬«      ƒ d {  –—†  y | j                  | j                  j                  k7  r%| j                  j                  |¬«      ƒ d {  –—†  y 	 |}| j                  j                  j                  «       r-| j                  j                  j                  |«      ƒ d {  –—† }| j                  €y | j                  j	                  «       r| j                  j                  «        y | j                  j                  �~t!        j"                  |«      4 ƒd {  –—†  | j                  j                  «       ƒ d {  –—†  | j                  j                  | j                  «      ƒ d {  –—†  d d d «      ƒd {  –—†  n$| j                  j%                  |¬«      ƒ d {  –—†  | j-                  «        | j/                  «        y 7 �Œ½7 �Œx7 �Œ&7 Œ²7 Œ’7 Œg7 ŒY# 1 ƒd {  –—†7  sw Y   ŒDxY w7 ŒK# t&        t(        j*                  f$ r4}	 | j                  �| j                  j                  «        |‚# |‚xY wd }~ww xY w­w)NzAPoolConnectionHolder.release() called on a free connection holderr�   )rr   r   rƒ   rH   r}   Ú	terminatert   Ú	_protocolÚqueries_countro   r†   ru   rl   Ú_is_cancellingÚ_wait_for_cancellationÚ_resetr   r‘   Úresetr“   r$   r”   Ú_releaserŒ   )r   r‘   Úbudgetr—   s       r   ÚreleasezPoolConnectionHolder.releaseß   sF  è ø€ Ø�<‰<ÐÜ×0Ñ0ð+ó,ð ,ð �9‰9×ÑÔ ð �I‰I×ÑÔ!ØàˆŒà�9‰9×Ñ×,Ñ,°×0AÑ0AÒAð —)‘)—/‘/¨'�/Ó2×2Ð2Øà×Ñ˜tŸz™z×5Ñ5Ò5ð —)‘)—/‘/¨'�/Ó2×2Ð2Øð"	ØˆFà�y‰y×"Ñ"×1Ñ1Ô3ð  $Ÿy™y×2Ñ2×IÑIØó ÷ �ð �y‰yÐ ØØ�y‰y×"Ñ"Ô$Ø—	‘	×#Ñ#Ô%Øà�z‰z× Ñ Ð,Ü!Ÿ>™>¨&×1Õ1ØŸ)™)×*Ñ*Ó,×,Ð,ØŸ*™*×+Ñ+¨D¯I©IÓ6×6Ð6÷ 2×1Ð1ð —i‘i—o‘o¨f�oÓ5×5Ð5ð 	�‰Œð 	×%Ñ%Õ'ðg 3ùð 3ùðùð 2øØ,øØ6øð 2ø×1×1Ñ1úð 6ùÜœ7×1Ñ1Ð2ò 
	ðð —9‘9Ð(Ø—I‘I×'Ñ'Ô)à�ø�b�þð
	üsþ   ‚B*K!Â,I)Â-AK!Ã4I,Ã5K!Ã;AJ Å	I/Å
J ÅK!Å4J ÆK!Æ/J Æ?I2Ç J ÇI:Ç!I4Ç",I:ÈI6ÈI:ÈJ ÈI8È$J ÉJÉJ É"K!É,K!É/J É2J É4I:É6I:É8J É:JÊ JÊJÊJ ÊKÊ+&KËKËKËKËKËK!c              ƒ  óR   K  — | j                   €y | j                   ƒ d {  –—†  y 7 Œ­wrX   r   rd   s    r   Úwait_until_releasedz(PoolConnectionHolder.wait_until_released&  s    è ø€ Ø�<‰<ÐØà—,‘,×Òús   ‚'Ÿ% 'c              ƒ  ón   K  — | j                   �#| j                   j                  «       ƒ d {  –—†  y y 7 Œ­wrX   )rH   r†   rd   s    r   r†   zPoolConnectionHolder.close,  s0   è ø€ Ø�9‰9Ð ð —)‘)—/‘/Ó#×#Ñ#ð !ð $ús   ‚*5¬3­5c                óR   — | j                   �| j                   j                  «        y y rX   )rH   rš   rd   s    r   rš   zPoolConnectionHolder.terminate2  s#   € Ø�9‰9Ð ð �I‰I×ÑÕ!ð !r    c                óÞ   — | j                   �t        j                  d«      ‚| j                  r@| j                  j
                  j                  | j                  | j                  «      | _         y y )Nz/pool connection inactivity timer already exists)rs   r   rƒ   rq   rl   rm   Ú
call_laterÚ_deactivate_inactive_connectionrd   s    r   rŒ   z-PoolConnectionHolder._setup_inactive_callback8  se   € Ø×"Ñ"Ð.Ü×0Ñ0ØAóCð Cð ×"Ò"Ø&*§j¡j×&6Ñ&6×&AÑ&AØ×'Ñ'¨×)MÑ)Mó'OˆDÕ#ð #r    c                ó`   — | j                   �"| j                   j                  «        d | _         y y rX   )rs   Úcancelrd   s    r   r‹   z4PoolConnectionHolder._maybe_cancel_inactive_callbackA  s-   € Ø×"Ñ"Ð.Ø×#Ñ#×*Ñ*Ô,Ø&*ˆDÕ#ð /r    c                ób  — | j                   �t        j                  d«      ‚d | _        | j                  �{| j                  «       rP| j                  j                  «       s6| j                  j                  «       | j                  j                  «       k  ry | j                  j                  «        y y )Nz/attempting to deactivate an acquired connection)rr   r   rƒ   rs   rH   r   rl   r…   Úget_sizeÚget_min_sizerš   rd   s    r   rª   z4PoolConnectionHolder._deactivate_inactive_connectionF  s‘   € Ø�<‰<Ð#Ü×0Ñ0ØAóCð Cð #'ˆÔØ�9‰9Ð Ø×!Ñ!Ô#¨D¯J©J×,AÑ,AÔ,CØ—J‘J×'Ñ'Ó)¨T¯Z©Z×-DÑ-DÓ-FÒFð ð �I‰I×ÑÕ!ð !r    c                ó†   — | j                  «        | j                  «        d | _        | j                  j	                  «        y rX   )r‹   r¡   rH   rl   Ú_schedule_min_size_maintenancerd   s    r   Ú_release_on_closez&PoolConnectionHolder._release_on_closeW  s.   € Ø×,Ñ,Ô.Ø�‰ŒØˆŒ	Ø�
‰
×1Ñ1Õ3r    c                ó:  — | j                   €y| j                   j                  «       s| j                   j                  d«       d| _         | j                  �!| j                  j	                  «        d| _        | j
                  j                  j                  | «       y)zRelease this connection holder.N)rr   ÚdoneÚ
set_resultrn   r`   rl   r   Ú
put_nowaitrd   s    r   r¡   zPoolConnectionHolder._release]  su   € à�<‰<Ðàà�|‰|× Ñ Ô"Ø�L‰L×#Ñ# DÔ)ØˆŒð �;‰;Ð"Ø�K‰K×ÑÔ!ØˆDŒKð 	�
‰
×Ñ×$Ñ$ TÕ*r    N)
rx   z'Pool'ry   Úfloatrz   z:Optional[Callable[[PoolConnectionProxy], Awaitable[None]]]r{   r·   rO   rg   )rO   rR   )rO   rg   )rO   rU   )r‘   úOptional[float]rO   rg   )r(   r)   r*   rh   r[   r   r€   rŽ   r˜   r£   r¥   r†   rš   rŒ   r‹   rª   r²   r¡   ri   r    r   rf   rf   ‚   s…   „ ð/€Ið/àð/ð ð	/ð
 Jð/ð !ð/ð 
ó/ó*Có ó(ó*#óJE(óNó$ó"óOó+ó
"ó"4ô+r    rf   c                  ó°  — e Zd ZdZdZddddddœd„Zd„ Zd„ Zd„ Zd	„ Z	d
„ Z
d„ Zd„ Zd„ Zd„ Zd„ Zd1d„Zd„ Zddœ	 	 	 	 	 d2d„Zddœ	 	 	 d3d„Zdddœ	 d4d„Zdddœd„Zdddœd„Zdddœd„Zdddddddddddddœd„Zdddddddddddœ
d„Zddddddddddddddddd œd!„Zddddd"œd#„Zddœd$„Zd%„ Zddœd&„Zd'„ Zd(„ Z d)„ Z!d*„ Z"d+„ Z#d,„ Z$d-„ Z%d.„ Z&d/„ Z'd0„ Z(y)5ÚPoola�  A connection pool.

    Connection pool can be used to manage a set of connections to the database.
    Connections are first acquired from the pool, then used, and then released
    back to the pool.  Once a connection is released, it's reset to close all
    open cursors and other resources *except* prepared statements.

    Pools are created by calling :func:`~asyncpg.pool.create_pool`.
    )r   rm   Ú	_initsizeÚ_minsizeÚ_maxsizeÚ_initÚ_connectrŸ   Ú_connect_argsÚ_connect_kwargsÚ_holdersÚ_initializedÚ_initializingÚ_closingÚ_closedÚ_connection_classÚ_record_classru   rp   ro   Ú!_max_inactive_connection_lifetimeÚ_maintenance_taskN)Ú	init_sizerŽ   rz   Úinitr    c               ó´  — t        |«      dkD  rt        j                  dt        d¬«       |
€t	        j
                  «       }
|
| _        |dk  rt        d«      ‚|dk  rt        d«      ‚||kD  rt        d«      ‚|€|}|dk  rt        d	«      ‚||kD  rt        d
«      ‚||k  rt        d«      ‚|dk  rt        d«      ‚|dk  rt        d«      ‚t        |t        j                  «      st        dj                  |«      «      ‚t        |t        j                  «      st        dj                  |«      «      ‚|| _        || _        || _        g | _        d| _        d| _        d | _        || _        || _        d| _        d| _        d| _        d | _        |�|nt        j8                  | _        || _        || _        || _         || _!        |	| _"        || _#        || _$        y )Nr
   z°Passing multiple positional arguments to asyncpg.Pool constructor is deprecated and will be removed in asyncpg 0.17.0.  The non-deprecated form is asyncpg.Pool(<dsn>, **kwargs)é   )Ú
stacklevelr   z,max_size is expected to be greater than zeroz3min_size is expected to be greater or equal to zeroz!min_size is greater than max_sizez4init_size is expected to be greater or equal to zeroz"init_size is greater than max_sizez"init_size is smaller than min_sizez/max_queries is expected to be greater than zerozKmax_inactive_connection_lifetime is expected to be greater or equal to zerozMconnection_class is expected to be a subclass of asyncpg.Connection, got {!r}zErecord_class is expected to be a subclass of asyncpg.Record, got {!r}F)%r   ÚwarningsÚwarnÚDeprecationWarningr$   Úget_event_looprm   Ú
ValueErrorÚ
issubclassr   r4   Ú	TypeErrorrJ   r   ÚRecordr»   r¼   r½   rÂ   rÃ   rÄ   r   rÇ   rÈ   rÅ   rÆ   ru   rÊ   rŽ   r¿   rÀ   rÁ   rp   r¾   rŸ   ro   rÉ   )r   rË   Úmin_sizeÚmax_sizery   Ú max_inactive_connection_lifetimerŽ   rz   rÌ   r    ÚloopÚconnection_classÚrecord_classÚconnect_argsÚconnect_kwargss                  r   r[   zPool.__init__…  s  € ô ˆ|Ó˜qÒ Ü�M‰Mð0ô #¨qõ2ð ˆ<Ü×)Ñ)Ó+ˆDØˆŒ
à�qŠ=ÜÐKÓLÐLà�aŠ<ÜØEóGð Gð �hÒÜÐ@ÓAÐAàÐØ ˆIà�qŠ=ÜØFóHð Hð �xÒÜÐAÓBÐBà�xÒÜÐAÓBÐBà˜!ÒÜÐNÓOÐOà+¨aÒ/Üð#ó$ð $ô Ð*¬J×,AÑ,AÔBÜð/ß/5©vÐ6FÓ/GóIð Iô ˜,¬¯©Ô8Üð+ß+1©6°,Ó+?óAð Að #ˆŒØ ˆŒØ ˆŒàˆŒØ!ˆÔØ"ˆÔØˆŒà!1ˆÔØ)ˆÔàˆŒØˆŒØˆÔØ!%ˆÔà#*Ð#6™¼J×<NÑ<NˆŒØ)ˆÔØ-ˆÔàˆŒØˆŒ
ØˆŒà'ˆÔà,ð 	Õ.r    c              ƒ  ó   K  — | j                   r| S | j                  rt        j                  d«      ‚| j                  rt        j                  d«      ‚d| _        	 | j                  «       ƒ d {  –—†  | d| _        d| _         | j                  «        S 7 Œ$# t        t        j                  f$ r* d| _        | j                  D ]  }|j                  «        Œ ‚ w xY w# d| _        d| _         | j                  «        w xY w­w)Nz)pool is being initialized in another taskúpool is closedTF)rÃ   rÄ   r   rI   rÆ   Ú_initializer±   r“   r$   r”   rÂ   rš   )r   r&   s     r   Ú_async__init__zPool._async__init__æ  sí   è ø€ Ø×ÒØˆKØ×ÒÜ×+Ñ+Ø;ó=ð =à�<Š<Ü×+Ñ+Ð,<Ó=Ð=Ø!ˆÔð	2Ø×"Ñ"Ó$×$Ð$Øð "'ˆDÔØ $ˆDÔØ×/Ñ/Õ1ð %ùäœ7×1Ñ1Ð2ò 	àˆDŒLØŸ-œ-�Ø× Ñ Õ"ð (àð	ûð "'ˆDÔØ $ˆDÔØ×/Ñ/Õ1üs=   ‚AC>ÁB Á.BÁ/B Á4C>ÂB ÂACÃC Ã C;Ã;C>c              ƒ  ó¼  K  — t        | j                  ¬«      | _        t        | j                  «      D ]e  }t	        | | j
                  | j                  | j                  ¬«      }| j                  j                  |«       | j                  j                  |«       Œg | j                  r°| j                  d   }|j                  «       ƒ d {  –—†  | j                  dkD  ryg }t        t        | j                  d d «      «      D ]8  \  }}|| j                  dz
  k\  r n!|j                  |j                  «       «       Œ: t        j                   |Ž ƒ d {  –—†  y y y 7 ŒŽ7 Œ	­w)N)Úmaxsize)ry   r{   rz   r   r
   )r   r½   r   r   rf   ro   rÉ   rp   rÂ   Úappendr¶   r»   rŽ   Ú	enumerateÚreversedr$   Úgather)r   r2   ÚchÚfirst_chÚconnect_tasksr   s         r   râ   zPool._initializeý  s&  è ø€ Ü0¸¿¹ÔGˆŒÜ�t—}‘}Ö%ˆAÜ%ØØ ×-Ñ-Ø"&×"HÑ"HØ—k‘kô	#ˆBð �M‰M× Ñ  Ô$Ø�K‰K×"Ñ" 2Õ&ð &ð �>Š>ð —}‘} RÑ(ˆHØ×"Ñ"Ó$×$Ð$à�~‰~ Ò!Ø "�Ü&¤x°·±¸c¸rÐ0BÓ'CÖD‘E�A�rà˜DŸN™N¨QÑ.Ò.ÙØ!×(Ñ(¨¯©«Õ6ð	 Eô —n‘n mÐ4×4Ñ4ð "ð ð %øð 5ús%   ‚CEÃ	EÃ
BEÅEÅEÅEc                ó  — | j                   r4| j                  s(| j                  «       s| j                  r| j                  �y | j                  «       | j                  k  r/| j                  j                  | j                  «       «      | _        y y rX   )	rÃ   rÄ   r…   r¼   rÊ   r®   rm   r’   Ú_maintain_min_sizerd   s    r   r±   z#Pool._schedule_min_size_maintenance  sk   € Ø×!Ò! T×%7Ò%7¸4¿?¹?Ô;LØ—}’}¨×(>Ñ(>Ð(JØØ�=‰=‹?˜TŸ]™]Ò*Ø%)§Z¡Z×%;Ñ%;Ø×'Ñ'Ó)ó&+ˆDÕ"ð +r    c              ƒ  ó’  K  — d}	 | j                  «       sé| j                  «       | j                  k  rÌ	 | j                  j	                  «       }d}	 |j                  �|j                  «        |j                  «       ƒ d {  –—†  | j                  j                  |«       |r-t        j                   |«      ƒ d {  –—†  t#        |dz  d«      }nd}| j                  «       s| j                  «       | j                  k  rŒÌd | _        y # t
        j                  $ r
 Y d | _        y w xY w7 Œ¦# t
        j                  $ r ‚ t        $ rQ | j                  «       r$Y | j                  j                  |«       d | _        y d}t        j                  dd¬«       Y �Œw xY w# | j                  j                  |«       w xY w7 Œþ# d | _        w xY w­w)Ng      ð?FTz5Failed to restore the pool connection floor; retrying)Úexc_inforÎ   g      N@)r…   r®   r¼   r   r'   r$   r%   rÊ   rH   rš   rŽ   r”   r“   r¶   ÚloggerÚwarningÚsleepÚmin)r   Úretry_delayr&   Úfaileds       r   rî   zPool._maintain_min_size&  s•  è ø€ Øˆð	*Ø—o‘oÔ'¨D¯M©M«O¸d¿m¹mÒ,KðØ!Ÿ[™[×@Ñ@ÓB�Fð
 �ð3Ø—{‘{Ð.Ø×(Ñ(Ô*Ø Ÿ.™.Ó*×*Ð*ð —K‘K×*Ñ*¨6Ô2áÜ!Ÿ-™-¨Ó4×4Ð4Ü"% k°A¡o°tÓ"<‘Kà"%�Kð7 —o‘oÔ'¨D¯M©M«O¸d¿m¹mÓ,Kð: &*ˆDÕ"øô5 ×)Ñ)ò àð0 &*ˆDÕ"ð5úð +ùÜ×-Ñ-ò ØÜ ò EØ—‘Ô(Øð
 —K‘K×*Ñ*¨6Ô2ð &*ˆDÕ"ð "�FÜ—N‘Nð $5Ø?Cð #÷ Eð	Eûð —K‘K×*Ñ*¨6Õ2úð 5ùð
 &*ˆDÕ"üs¬   ‚G†-F; ´D ÁF; Á/D) Â D'ÂD) Â5F; Â:F9Â;AF; Ã?GÄD$ÄF; ÄGÄ#D$Ä$F; Ä'D) Ä),FÅF ÅF; Å1GÅ9FÆF ÆFÆF ÆF6Æ6F; Æ;	GÇGc                ó6   — | j                   xs | j                  S )z_Return ``True`` if the pool is closing or is closed.

        .. versionadded:: 0.28.0
        )rÆ   rÅ   rd   s    r   r…   zPool.is_closingH  s   € ð
 �|‰|Ò,˜tŸ}™}Ð,r    c                ó:   — t        d„ | j                  D «       «      S )zaReturn the current number of connections in this pool.

        .. versionadded:: 0.25.0
        c              3  ó<   K  — | ]  }|j                  «       –— Œ y ­wrX   )r   ©Ú.0Úhs     r   Ú	<genexpr>z Pool.get_size.<locals>.<genexpr>T  s   è ø€ Ð;©]¨�1—>‘>×#©]ùs   ‚©ÚsumrÂ   rd   s    r   r®   zPool.get_sizeO  s   € ô
 Ñ;¨T¯]ª]Ó;Ó;Ð;r    c                ó   — | j                   S )zaReturn the initial number of connections in this pool.

        .. versionadded:: 0.32.0
        )r»   rd   s    r   Úget_init_sizezPool.get_init_sizeV  s   € ð
 �~‰~Ðr    c                ó   — | j                   S )a  Return the minimum number of connections in this pool.

        .. versionadded:: 0.25.0

        .. versionchanged:: 0.32.0
            The parameter now controls the connection floor rather than the
            initial pool size (see ``init_size``).
        )r¼   rd   s    r   r¯   zPool.get_min_size]  s   € ð �}‰}Ðr    c                ó   — | j                   S )ziReturn the maximum allowed number of connections in this pool.

        .. versionadded:: 0.25.0
        )r½   rd   s    r   Úget_max_sizezPool.get_max_sizeh  s   € ð
 �}‰}Ðr    c                ó:   — t        d„ | j                  D «       «      S )zfReturn the current number of idle connections in this pool.

        .. versionadded:: 0.25.0
        c              3  ó`   K  — | ]&  }|j                  «       xr |j                  «       –— Œ( y ­wrX   )r   r€   rú   s     r   rý   z%Pool.get_idle_size.<locals>.<genexpr>t  s&   è ø€ ÐK¹]¸�1—>‘>Ó#Ò3¨¯	©	«Ó3¹]ùs   ‚,.rþ   rd   s    r   Úget_idle_sizezPool.get_idle_sizeo  s   € ô
 ÑK¸T¿]º]ÓKÓKÐKr    c                ó"   — |g| _         || _        y)aÊ  Set the new connection arguments for this pool.

        The new connection arguments will be used for all subsequent
        new connection attempts.  Existing connections will remain until
        they expire. Use :meth:`Pool.expire_connections()
        <asyncpg.pool.Pool.expire_connections>` to expedite the connection
        expiry.

        :param str dsn:
            Connection arguments specified using as a single string in
            the following format:
            ``postgres://user:pass@host:port/database?option=value``.

        :param \*\*connect_kwargs:
            Keyword arguments for the :func:`~asyncpg.connection.connect`
            function.

        .. versionadded:: 0.16.0
        N)rÀ   rÁ   )r   Údsnrß   s      r   Úset_connect_argszPool.set_connect_argsv  s   € ð* "˜UˆÔØ-ˆÕr    c              ƒ  óÂ  K  —  | j                   | j                  | j                  | j                  | j                  dœ| j
                  ¤Žƒ d {  –—† }t        || j                  «      s…| j                  }|j                  › d|j                  › �}t        |«      }|j                  dk(  r|j                  }n|j                  › d|j                  › �}t        j                  d|› d|› d�«      ‚| j                  �	 | j                  |«      ƒ d {  –—†  |S |S 7 ŒÉ7 Œ
# t        t        j                  f$ r'}	 |j!                  «       ƒ d {  –—†7   |‚# |‚xY wd }~ww xY w­w)N)rÛ   rÜ   rÝ   Ú.Úbuiltinsz9expected pool connect callback to return an instance of 'z', got 'Ú')r¿   rÀ   rm   rÇ   rÈ   rÁ   Ú
isinstancer)   r(   Útyper   rI   r¾   r“   r$   r”   r†   )r   rZ   ÚgoodÚgood_nÚbadÚbad_nr—   s          r   r„   zPool._get_new_connectionŽ  sW  è ø€ Ø!�D—M‘MØ×ÑØ—‘Ø!×3Ñ3Ø×+Ñ+ñ	
ð
 ×"Ñ"ñ
÷ 
ˆô ˜#˜t×5Ñ5Ô6Ø×)Ñ)ˆDØŸ™Ð(¨¨$¯-©-¨Ð9ˆFÜ�s“)ˆCØ�~‰~ Ò+ØŸ™‘àŸ>™>Ð*¨!¨C¯L©L¨>Ð:�Ü×+Ñ+ðØ�8˜<¨ w¨að1óð ð
 �:‰:Ð!ðØ—j‘j “o×%Ð%ð ˆ
ˆsˆ
ðK
øð, &ùÜœw×5Ñ5Ð6ò ð
ð
 Ÿ)™)›+×%Ñ%à�Hø˜"�Hþðüsg   ‚AEÁDÁB+EÃ;D ÄDÄD ÄEÄD ÄEÄ6EÅ	EÅ
EÅEÅEÅEÅEÅEr�   c             ‡  óÐ   K  — | j                  «       4 ƒd{  –—† } |j                  |g|¢­d|iŽƒ d{  –—† cddd«      ƒd{  –—†  S 7 Œ37 Œ7 Œ	# 1 ƒd{  –—†7  sw Y   yxY w­w)a  Execute an SQL command (or commands).

        Pool performs this operation using one of its connections.  Other than
        that, it behaves identically to
        :meth:`Connection.execute() <asyncpg.connection.Connection.execute>`.

        .. versionadded:: 0.10.0
        Nr‘   )r˜   Úexecute)r   Úqueryr‘   rK   rZ   s        r   r  zPool.execute¶  sJ   è ø€ ð —<‘<—>”> SØ$˜Ÿ™ UÐC¨TÒC¸7ÑC×C÷ "—>’>øØCøð "ø—>—>‘>üsS   ‚A&—A˜A&›AµA¶A¹A&ÁAÁA&ÁAÁA&ÁA#ÁAÁA#ÁA&c             ƒ  óÌ   K  — | j                  «       4 ƒd{  –—† }|j                  |||¬«      ƒ d{  –—† cddd«      ƒd{  –—†  S 7 Œ17 Œ7 Œ	# 1 ƒd{  –—†7  sw Y   yxY w­w)aC  Execute an SQL *command* for each sequence of arguments in *args*.

        Pool performs this operation using one of its connections.  Other than
        that, it behaves identically to
        :meth:`Connection.executemany()
        <asyncpg.connection.Connection.executemany>`.

        .. versionadded:: 0.10.0
        Nr�   )r˜   Úexecutemany)r   ÚcommandrK   r‘   rZ   s        r   r  zPool.executemanyÇ  sD   è ø€ ð  —<‘<—>”> SØŸ™¨°$À˜ÓH×H÷ "—>’>øØHøð "ø—>—>‘>üsS   ‚A$—A	˜A$›A³A´A·A$ÁAÁA$ÁAÁA$ÁA!ÁAÁA!ÁA$©r‘   rÝ   c             ‡  óÒ   K  — | j                  «       4 ƒd{  –—† } |j                  |g|¢­||dœŽƒ d{  –—† cddd«      ƒd{  –—†  S 7 Œ47 Œ7 Œ	# 1 ƒd{  –—†7  sw Y   yxY w­w)a-  Run a query and return the results as a list of :class:`Record`.

        Pool performs this operation using one of its connections.  Other than
        that, it behaves identically to
        :meth:`Connection.fetch() <asyncpg.connection.Connection.fetch>`.

        .. versionadded:: 0.10.0
        Nr  )r˜   Úfetch©r   r  r‘   rÝ   rK   rZ   s         r   r  z
Pool.fetchÚ  s\   è ø€ ð —<‘<—>”> SØ"˜Ÿ™Øðàñð  Ø)ò	÷ ÷ "—>’>øðøð "ø—>—>‘>üóS   ‚A'—A˜A'›A¶A·AºA'ÁAÁA'ÁAÁA'ÁA$ÁAÁA$Á A'r   ©Úcolumnr‘   c             ‡  óÒ   K  — | j                  «       4 ƒd{  –—† } |j                  |g|¢­||dœŽƒ d{  –—† cddd«      ƒd{  –—†  S 7 Œ47 Œ7 Œ	# 1 ƒd{  –—†7  sw Y   yxY w­w)a+  Run a query and return a value in the first row.

        Pool performs this operation using one of its connections.  Other than
        that, it behaves identically to
        :meth:`Connection.fetchval()
        <asyncpg.connection.Connection.fetchval>`.

        .. versionadded:: 0.10.0
        Nr   )r˜   Úfetchval)r   r  r!  r‘   rK   rZ   s         r   r#  zPool.fetchvalñ  sY   è ø€ ð —<‘<—>”> SØ%˜Ÿ™Øð>Øñ>Ø%+°Wò>÷ >÷ "—>’>øð>øð "ø—>—>‘>ür  c             ‡  óÒ   K  — | j                  «       4 ƒd{  –—† } |j                  |g|¢­||dœŽƒ d{  –—† cddd«      ƒd{  –—†  S 7 Œ47 Œ7 Œ	# 1 ƒd{  –—†7  sw Y   yxY w­w)a  Run a query and return the first row.

        Pool performs this operation using one of its connections.  Other than
        that, it behaves identically to
        :meth:`Connection.fetchrow() <asyncpg.connection.Connection.fetchrow>`.

        .. versionadded:: 0.10.0
        Nr  )r˜   Úfetchrowr  s         r   r%  zPool.fetchrowÿ  s\   è ø€ ð —<‘<—>”> SØ%˜Ÿ™Øðàñð  Ø)ò	÷ ÷ "—>’>øðøð "ø—>—>‘>ür  c             ƒ  óÎ   K  — | j                  «       4 ƒd{  –—† }|j                  ||||¬«      ƒ d{  –—† cddd«      ƒd{  –—†  S 7 Œ27 Œ7 Œ	# 1 ƒd{  –—†7  sw Y   yxY w­w)an  Run a query for each sequence of arguments in *args*
        and return the results as a list of :class:`Record`.

        Pool performs this operation using one of its connections.  Other than
        that, it behaves identically to
        :meth:`Connection.fetchmany()
        <asyncpg.connection.Connection.fetchmany>`.

        .. versionadded:: 0.30.0
        Nr  )r˜   Ú	fetchmany)r   r  rK   r‘   rÝ   rZ   s         r   r'  zPool.fetchmany  sP   è ø€ ð —<‘<—>”> SØŸ™Ø�t W¸<ð 'ó ÷ ÷ "—>’>øðøð "ø—>—>‘>üsS   ‚A%—A
˜A%›A´AµA¸A%ÁAÁA%ÁAÁA%ÁA"ÁAÁA"ÁA%)ÚcolumnsÚschema_namer‘   rJ   ÚoidsÚ	delimiterÚnullÚheaderÚquoteÚescapeÚforce_quoteÚencodingc             ƒ  óâ   K  — | j                  «       4 ƒd{  –—† }|j                  |||||||||	|
||||¬«      ƒ d{  –—† cddd«      ƒd{  –—†  S 7 Œ<7 Œ7 Œ	# 1 ƒd{  –—†7  sw Y   yxY w­w)a;  Copy table contents to a file or file-like object.

        Pool performs this operation using one of its connections.  Other than
        that, it behaves identically to
        :meth:`Connection.copy_from_table()
        <asyncpg.connection.Connection.copy_from_table>`.

        .. versionadded:: 0.24.0
        N)Úoutputr(  r)  r‘   rJ   r*  r+  r,  r-  r.  r/  r0  r1  )r˜   Úcopy_from_table)r   Ú
table_namer3  r(  r)  r‘   rJ   r*  r+  r,  r-  r.  r/  r0  r1  rZ   s                   r   r4  zPool.copy_from_table   ss   è ø€ ð6 —<‘<—>”> SØ×,Ñ,ØØØØ'ØØØØ#ØØØØØ'Ø!ð -ó ÷ ÷ "—>’>øðøð "ø—>—>‘>üsT   ‚A/—A˜A/›#A¾A¿AÁA/ÁAÁA/ÁAÁA/ÁA,Á A#Á!A,Á(A/)
r‘   rJ   r*  r+  r,  r-  r.  r/  r0  r1  c             ‡  óä   K  — | j                  «       4 ƒd{  –—† } |j                  |g|¢­||||||||	|
||dœŽƒ d{  –—† cddd«      ƒd{  –—†  S 7 Œ=7 Œ7 Œ	# 1 ƒd{  –—†7  sw Y   yxY w­w)aC  Copy the results of a query to a file or file-like object.

        Pool performs this operation using one of its connections.  Other than
        that, it behaves identically to
        :meth:`Connection.copy_from_query()
        <asyncpg.connection.Connection.copy_from_query>`.

        .. versionadded:: 0.24.0
        N)r3  r‘   rJ   r*  r+  r,  r-  r.  r/  r0  r1  )r˜   Úcopy_from_query)r   r  r3  r‘   rJ   r*  r+  r,  r-  r.  r/  r0  r1  rK   rZ   s                  r   r7  zPool.copy_from_queryM  sy   è ø€ ð2 —<‘<—>”> SØ,˜×,Ñ,Øðàñð ØØØØ#ØØØØØ'Ø!ò÷ ÷ "—>’>øðøð "ø—>—>‘>üsU   ‚A0—A˜A0›$A¿AÁ AÁA0ÁAÁA0ÁAÁA0ÁA-Á!A$Á"A-Á)A0)r(  r)  r‘   rJ   r*  Úfreezer+  r,  r-  r.  r/  r0  Úforce_not_nullÚ
force_nullr1  Úwherec             ƒ  óê   K  — | j                  «       4 ƒd{  –—† }|j                  |||||||||	|
||||||||¬«      ƒ d{  –—† cddd«      ƒd{  –—†  S 7 Œ@7 Œ7 Œ	# 1 ƒd{  –—†7  sw Y   yxY w­w)a&  Copy data to the specified table.

        Pool performs this operation using one of its connections.  Other than
        that, it behaves identically to
        :meth:`Connection.copy_to_table()
        <asyncpg.connection.Connection.copy_to_table>`.

        .. versionadded:: 0.24.0
        N)Úsourcer(  r)  r‘   rJ   r*  r8  r+  r,  r-  r.  r/  r0  r9  r:  r1  r;  )r˜   Úcopy_to_table)r   r5  r=  r(  r)  r‘   rJ   r*  r8  r+  r,  r-  r.  r/  r0  r9  r:  r1  r;  rZ   s                       r   r>  zPool.copy_to_tablew  s   è ø€ ð> —<‘<—>”> SØ×*Ñ*ØØØØ'ØØØØØ#ØØØØØ'Ø-Ø%Ø!Øð% +ó ÷ ÷ "—>’>øðøð "ø—>—>‘>üsV   ‚A3—A˜A3›'AÁAÁAÁA3ÁAÁA3ÁAÁA3ÁA0Á$A'Á%A0Á,A3)r(  r)  r‘   r;  c          	   ƒ  óÒ   K  — | j                  «       4 ƒd{  –—† }|j                  ||||||¬«      ƒ d{  –—† cddd«      ƒd{  –—†  S 7 Œ47 Œ7 Œ	# 1 ƒd{  –—†7  sw Y   yxY w­w)aU  Copy a list of records to the specified table using binary COPY.

        Pool performs this operation using one of its connections.  Other than
        that, it behaves identically to
        :meth:`Connection.copy_records_to_table()
        <asyncpg.connection.Connection.copy_records_to_table>`.

        .. versionadded:: 0.24.0
        N)Úrecordsr(  r)  r‘   r;  )r˜   Úcopy_records_to_table)r   r5  r@  r(  r)  r‘   r;  rZ   s           r   rA  zPool.copy_records_to_table¬  s[   è ø€ ð& —<‘<—>”> SØ×2Ñ2ØØØØ'ØØð 3ó ÷ ÷ "—>’>øðøð "ø—>—>‘>ür  c               ó   — t        | |«      S )aT  Acquire a database connection from the pool.

        :param float timeout: A timeout for acquiring a Connection.
        :return: An instance of :class:`~asyncpg.connection.Connection`.

        Can be used in an ``await`` expression or with an ``async with`` block.

        .. code-block:: python

            async with pool.acquire() as con:
                await con.execute(...)

        Or:

        .. code-block:: python

            con = await pool.acquire()
            try:
                await con.execute(...)
            finally:
                await pool.release(con)
        )ÚPoolAcquireContext)r   r‘   s     r   r˜   zPool.acquireÉ  s   € ô. " $¨Ó0Ð0r    c              ƒ  óî   ‡ ‡K  — ˆ ˆfd„}‰ j                   rt        j                  d«      ‚‰ j                  «        ‰€ |«       ƒ d {  –—† S t	        j
                   |«       ‰¬«      ƒ d {  –—† S 7 Œ(7 Œ­w)Nc               “  ó.  •K  — ‰j                   j                  «       ƒ d {  –—† } 	 | j                  «       ƒ d {  –—† }‰| _        |S 7 Œ&7 Œ# t        t
        j                  f$ r- ‰j                   j                  | «       ‰j                  «        ‚ w xY w­wrX   )	r   Úgetr˜   rt   r“   r$   r”   r¶   r±   )rê   r–   r   r‘   s     €€r   Ú_acquire_implz$Pool._acquire.<locals>._acquire_implã  s~   øè ø€ Ø—{‘{—‘Ó(×(ˆBð
Ø Ÿj™j›l×*�ð &�”Ø�ð )øà*ùÜœw×5Ñ5Ð6ò Ø—‘×&Ñ& rÔ*Ø×3Ñ3Ô5Øðüs6   ƒB¡A¢B§A ºA
»A ¿
BÁ
A ÁABÂBr‚   r�   )rÅ   r   rI   Ú_check_initr   Úwait_for)r   r‘   rG  s   `` r   Ú_acquirezPool._acquireâ  sk   ùè ø€ õ	ð �=Š=Ü×+Ñ+Ð,=Ó>Ð>Ø×ÑÔàˆ?Ù&›×(Ð(äŸ™Ù“¨ô2÷ 2ð 2ð )øð2ús$   „AA5ÁA1Á	#A5Á,A3Á-A5Á3A5c             ƒ  ó¤  K  — t        |«      t        us|j                  j                  | ur%t	        j
                  dj                  |¬«      «      ‚|j                  €y| j                  «        |j                  j                  «        |j                  }|€|j                  }t        j                  |j                  |«      «      ƒ d{  –—† S 7 Œ­w)añ  Release a database connection back to the pool.

        :param Connection connection:
            A :class:`~asyncpg.connection.Connection` object to release.
        :param float timeout:
            A timeout for releasing the connection.  If not specified, defaults
            to the timeout provided in the corresponding call to the
            :meth:`Pool.acquire() <asyncpg.pool.Pool.acquire>` method.

        .. versionchanged:: 0.14.0
            Added the *timeout* parameter.
        zWPool.release() received invalid connection: {connection!r} is not a member of this poolr   N)r  rU   rV   rl   r   rI   rJ   rH   rH  Ú_on_releasert   r$   Úshieldr£   )r   r   r‘   rê   s       r   r£   zPool.releaseû  s»   è ø€ ô �ÓÔ$7Ñ7Ø×"Ñ"×(Ñ(°Ñ4Ü×+Ñ+ð>ß>D¹fØ)ð ?Eó ?+ó,ð ,ð
 �?‰?Ð"àà×ÑÔð 	�‰×#Ñ#Ô%à×ÑˆØˆ?Ø—k‘kˆGô
 —^‘^ B§J¡J¨wÓ$7Ó8×8Ð8Ð8ús   ‚CCÃ	CÃ
Cc              ƒ  ó^  K  — | j                   ry| j                  «        d| _        d}	 | j                  �J| j                  j	                  «        t        j                  | j                  d¬«      ƒ d{  –—†  d| _        | j                  j                  d| j                  «      }| j                  D �cg c]  }|j                  «       ‘Œ }}t        j                  |Ž ƒ d{  –—†  | j                  D �cg c]  }|j                  «       ‘Œ }}t        j                  |Ž ƒ d{  –—†  	 |�|j	                  «        d| _         d| _        y7 ŒÕc c}w 7 Œnc c}w 7 Œ4# t        t
        j                  f$ r | j                  «        ‚ w xY w# |�|j	                  «        d| _         d| _        w xY w­w)aŠ  Attempt to gracefully close all connections in the pool.

        Wait until all pool connections are released, close them and
        shut down the pool.  If any error (including cancellation) occurs
        in ``close()`` the pool will terminate by calling
        :meth:`Pool.terminate() <pool.Pool.terminate>`.

        It is advisable to use :func:`python:asyncio.wait_for` to set
        a timeout.

        .. versionchanged:: 0.16.0
            ``close()`` now waits until all pool connections are released
            before closing them and the pool.  Errors raised in ``close()``
            will cause immediate pool termination.
        NT)Úreturn_exceptionsé<   F)rÆ   rH  rÅ   rÊ   r¬   r$   ré   rm   r©   Ú_warn_on_long_closerÂ   r¥   r†   r“   r”   rš   )r   Úwarning_callbackrê   Úrelease_corosÚclose_coross        r   r†   z
Pool.close!  s•  è ø€ ð  �<Š<ØØ×ÑÔàˆŒàÐð	"Ø×%Ñ%Ð1Ø×&Ñ&×-Ñ-Ô/Ü—n‘nØ×*Ñ*¸dôD÷ Dð Dà)-�Ô&à#Ÿz™z×4Ñ4Ø�D×,Ñ,ó .Ðð 48·=²=óBÙ3@¨R�×&Ñ&Õ(°=ð ð Bä—.‘. -Ð0×0Ð0ð &*§]¢]ó4Ù%2˜r�—‘•
 ]ð ð 4ä—.‘. +Ð.×.Ñ.ð  Ð+Ø ×'Ñ'Ô)ØˆDŒLØ!ˆD�Mð/DúòBà0úò4à.ùäœ7×1Ñ1Ð2ò 	Ø�N‰NÔØð	ûð
  Ð+Ø ×'Ñ'Ô)ØˆDŒLØ!ˆD�Müsw   ‚'F-ªA
E Á4E
Á5?E Â4EÃE Ã"EÃ#E Ã5EÄE Ä#EÄ$E Ä)!F-Å
E ÅE ÅE Å+FÆF Æ"F*Æ*F-c                ó.   — t         j                  d«       y )Nz Pool.close() is taking over 60 seconds to complete. Check if you have any unreleased connections left. Use asyncio.wait_for() to set a timeout for Pool.close().)rñ   rò   rd   s    r   rQ  zPool._warn_on_long_closeT  s   € Ü�‰ð 'õ 	(r    c                óÚ   — | j                   ry| j                  «        d| _         | j                  �| j                  j                  «        | j                  D ]  }|j                  «        Œ y)z&Terminate all connections in the pool.NT)rÆ   rH  rÊ   r¬   rÂ   rš   ©r   rê   s     r   rš   zPool.terminateZ  sT   € à�<Š<ØØ×ÑÔØˆŒØ×!Ñ!Ð-Ø×"Ñ"×)Ñ)Ô+Ø—-”-ˆBØ�L‰L�Nñ  r    c              ƒ  ó6   K  — | xj                   dz  c_         y­w)zÎExpire all currently open connections.

        Cause all currently open connections to get replaced on the
        next :meth:`~asyncpg.pool.Pool.acquire()` call.

        .. versionadded:: 0.16.0
        r
   N)ru   rd   s    r   Úexpire_connectionszPool.expire_connectionse  s   è ø€ ð 	×Ò˜AÑÖùs   ‚c                óÊ   — | j                   s6| j                  rt        j                  d«      ‚t        j                  d«      ‚| j                  rt        j                  d«      ‚y )Nzipool is being initialized, but not yet ready: likely there is a race between creating a pool and using itzpool is not initializedrá   )rÃ   rÄ   r   rI   rÆ   rd   s    r   rH  zPool._check_inito  s^   € Ø× Ò Ø×!Ò!Ü ×/Ñ/ðó ð  ô ×+Ñ+Ð,EÓFÐFØ�<Š<Ü×+Ñ+Ð,<Ó=Ð=ð r    c                ót   — | j                   D ])  }|j                  €Œ|j                  j                  «        Œ+ y rX   )rÂ   rH   Ú_drop_local_statement_cacherW  s     r   Ú_drop_statement_cachezPool._drop_statement_cachez  s*   € à—-”-ˆBØ�w‰wÑ"Ø—‘×3Ñ3Õ5ñ  r    c                ót   — | j                   D ])  }|j                  €Œ|j                  j                  «        Œ+ y rX   )rÂ   rH   Ú_drop_local_type_cacherW  s     r   Ú_drop_type_cachezPool._drop_type_cache€  s*   € à—-”-ˆBØ�w‰wÑ"Ø—‘×.Ñ.Õ0ñ  r    c                ó>   — | j                  «       j                  «       S rX   )rã   Ú	__await__rd   s    r   rb  zPool.__await__†  s   € Ø×"Ñ"Ó$×.Ñ.Ó0Ð0r    c              ƒ  óB   K  — | j                  «       ƒ d {  –—†  | S 7 Œ­wrX   )rã   rd   s    r   Ú
__aenter__zPool.__aenter__‰  s"   è ø€ Ø×!Ñ!Ó#×#Ð#Øˆð 	$ús   ‚–—c              ‡  ó@   K  — | j                  «       ƒ d {  –—†  y 7 Œ­wrX   )r†   )r   Úexcs     r   Ú	__aexit__zPool.__aexit__�  s   è ø€ Ø�j‰j‹l×Òús   ‚–—rX   )r  rQ   r‘   r¸   rO   rQ   )r  rQ   r‘   r¸   )rO   Úlist))r(   r)   r*   r+   rh   r[   rã   râ   r±   rî   r…   r®   r  r¯   r  r  r
  r„   r  r  r  r#  r%  r'  r4  r7  r>  rA  r˜   rJ  r£   r†   rQ  rš   rY  rH  r]  r`  rb  rd  rg  ri   r    r   rº   rº   q  sÖ  „ ñð€Ið  ð
 ØØØô_-òB2ò.5òB+ò *òD-ò<òò	òòLó.ò0&ðX "&ñ	DàðDð !ð	Dð
 
óDð, "&ñIàðIð
 !óIð. Øñð 
óð. 34¸Tô >ð 48Àdô ð" 7;Èô ð* ØØØØØØØØØØØô!+ðd ØØØØØØØØØô(ð^ ØØØØØØØØØØØØØØØô)3ðt ØØØôð: "&ô 1ò22ð2 48ô $9òL1"òf(ò	òò	>ò6ò1ò1òór    rº   c                  óB   — e Zd ZdZdd„Zd„ Z	 	 	 d	 	 	 	 	 	 	 d	d„Zd„ Zy)
rC  )r‘   r   r´   rx   c                ó<   — || _         || _        d | _        d| _        y )NF)rx   r‘   r   r´   )r   rx   r‘   s      r   r[   zPoolAcquireContext.__init__•  s   € ØˆŒ	ØˆŒØˆŒØˆ�	r    c              ƒ  óä   K  — | j                   €| j                  rt        j                  d«      ‚| j                  j                  | j                  «      ƒ d {  –—† | _         | j                   S 7 Œ­w)Nz a connection is already acquired)r   r´   r   rI   rx   rJ  r‘   rd   s    r   rd  zPoolAcquireContext.__aenter__›  sU   è ø€ Ø�?‰?Ð&¨$¯)ª)Ü×+Ñ+Ð,NÓOÐOØ $§	¡	× 2Ñ 2°4·<±<Ó @×@ˆŒØ�‰Ðð Aús   ‚AA0ÁA.ÁA0Nc              ƒ  óŠ   K  — d| _         | j                  }d | _        | j                  j                  |«      ƒ d {  –—†  y 7 Œ­w©NT)r´   r   rx   r£   )r   Úexc_typeÚexc_valÚexc_tbrZ   s        r   rg  zPoolAcquireContext.__aexit__¡  s7   è ø€ ð ˆŒ	Ø�o‰oˆØˆŒØ�i‰i×Ñ Ó$×$Ò$ús   ‚9A»A¼Ac                óv   — d| _         | j                  j                  | j                  «      j	                  «       S rm  )r´   rx   rJ  r‘   rb  rd   s    r   rb  zPoolAcquireContext.__await__¬  s+   € ØˆŒ	Ø�y‰y×!Ñ! $§,¡,Ó/×9Ñ9Ó;Ð;r    )rx   rº   r‘   r¸   rO   rg   )NNN)rn  zOptional[Type[BaseException]]ro  zOptional[BaseException]rp  zOptional[TracebackType]rO   rg   )r(   r)   r*   rh   r[   rd  rg  rb  ri   r    r   rC  rC  ‘  sL   „ à9€Ióòð 37Ø+/Ø*.ð		%à/ð	%ð )ð	%ð (ð		%ð
 
ó	%ó<r    rC  é
   iPÃ  g     Àr@)rË   rØ   rÙ   ry   rÚ   rŽ   rz   rÌ   r    rÛ   rÜ   rÝ   c               ó4   — t        | f|||||||
||||	|dœ|¤ŽS )uê  Create a connection pool.

    Can be used either with an ``async with`` block:

    .. code-block:: python

        async with asyncpg.create_pool(user='postgres',
                                       command_timeout=60) as pool:
            await pool.fetch('SELECT 1')

    Or to perform multiple operations on a single connection:

    .. code-block:: python

        async with asyncpg.create_pool(user='postgres',
                                       command_timeout=60) as pool:
            async with pool.acquire() as con:
                await con.execute('''
                   CREATE TABLE names (
                      id serial PRIMARY KEY,
                      name VARCHAR (255) NOT NULL)
                ''')
                await con.fetch('SELECT 1')

    Or directly with ``await`` (not recommended):

    .. code-block:: python

        pool = await asyncpg.create_pool(user='postgres', command_timeout=60)
        con = await pool.acquire()
        try:
            await con.fetch('SELECT 1')
        finally:
            await pool.release(con)

    .. warning::
        Prepared statements and cursors returned by
        :meth:`Connection.prepare() <asyncpg.connection.Connection.prepare>`
        and :meth:`Connection.cursor() <asyncpg.connection.Connection.cursor>`
        become invalid once the connection is released.  Likewise, all
        notification and log listeners are removed, and ``asyncpg`` will
        issue a warning if there are any listener callbacks registered on a
        connection that is being released to the pool.

    :param str dsn:
        Connection arguments specified using as a single string in
        the following format:
        ``postgres://user:pass@host:port/database?option=value``.

    :param \*\*connect_kwargs:
        Keyword arguments for the :func:`~asyncpg.connection.connect`
        function.

    :param Connection connection_class:
        The class to use for connections.  Must be a subclass of
        :class:`~asyncpg.connection.Connection`.

    :param type record_class:
        If specified, the class to use for records returned by queries on
        the connections in this pool.  Must be a subclass of
        :class:`~asyncpg.Record`.

    :param int init_size:
        Number of connections the pool will be initialized with.  Defaults
        to *min_size*.  Must be between *min_size* and *max_size*.

    :param int min_size:
        Minimum number of connections retained during idle periods.  Closed
        connections are replaced in the background to restore this floor.
        The pool may temporarily fall below it while reconnecting or while
        the server is unavailable.  Pass ``0`` to allow the pool to drain.

    :param int max_size:
        Max number of connections in the pool.

    :param int max_queries:
        Number of queries after a connection is closed and replaced
        with a new connection.

    :param float max_inactive_connection_lifetime:
        Number of seconds after which inactive connections in the
        pool above *min_size* will be closed.  Pass ``0`` to disable this
        mechanism.

    :param coroutine connect:
        A coroutine that is called instead of
        :func:`~asyncpg.connection.connect` whenever the pool needs to make a
        new connection.  Must return an instance of type specified by
        *connection_class* or :class:`~asyncpg.connection.Connection` if
        *connection_class* was not specified.

    :param coroutine setup:
        A coroutine to prepare a connection right before it is returned
        from :meth:`Pool.acquire()`.  An example use
        case would be to automatically set up notifications listeners for
        all connections of a pool.

    :param coroutine init:
        A coroutine to initialize a connection when it is created.
        An example use case would be to setup type codecs with
        :meth:`Connection.set_builtin_type_codec() <\
        asyncpg.connection.Connection.set_builtin_type_codec>`
        or :meth:`Connection.set_type_codec() <\
        asyncpg.connection.Connection.set_type_codec>`.

    :param coroutine reset:
        A coroutine to reset a connection before it is returned to the pool by
        :meth:`Pool.release()`.  The function is supposed
        to reset any changes made to the database session so that the next
        acquirer gets the connection in a well-defined state.

        The default implementation calls :meth:`Connection.reset() <\
        asyncpg.connection.Connection.reset>`, which runs the following::

            SELECT pg_advisory_unlock_all();
            CLOSE ALL;
            UNLISTEN *;
            RESET ALL;

        The exact reset query is determined by detected server capabilities,
        and a custom *reset* implementation can obtain the default query
        by calling :meth:`Connection.get_reset_query() <\
        asyncpg.connection.Connection.get_reset_query>`.

    :param loop:
        An asyncio event loop instance.  If ``None``, the default
        event loop will be used.

    :return: An instance of :class:`~asyncpg.pool.Pool`.

    .. versionchanged:: 0.10.0
       An :exc:`~asyncpg.exceptions.InterfaceError` will be raised on any
       attempted operation on a released connection.

    .. versionchanged:: 0.13.0
       An :exc:`~asyncpg.exceptions.InterfaceError` will be raised on any
       attempted operation on a prepared statement or a cursor created
       on a connection that has been released to the pool.

    .. versionchanged:: 0.13.0
       An :exc:`~asyncpg.exceptions.InterfaceWarning` will be produced
       if there are any active listeners (added via
       :meth:`Connection.add_listener()
       <asyncpg.connection.Connection.add_listener>`
       or :meth:`Connection.add_log_listener()
       <asyncpg.connection.Connection.add_log_listener>`) present on the
       connection at the moment of its release to the pool.

    .. versionchanged:: 0.22.0
       Added the *record_class* parameter.

    .. versionchanged:: 0.30.0
       Added the *connect* and *reset* parameters.

    .. versionchanged:: 0.32.0
       The *min_size* parameter now defines the connection floor.  The former
       role of *min_size* â€” setting the initial pool size â€” is now handled by
       the new *init_size* parameter, which defaults to *min_size*.
    )rÜ   rÝ   rË   rØ   rÙ   ry   rÛ   rŽ   rz   rÌ   r    rÚ   )rº   )r	  rË   rØ   rÙ   ry   rÚ   rŽ   rz   rÌ   r    rÛ   rÜ   rÝ   rß   s                 r   Úcreate_poolrt  ±  sH   € ôZ Øðà)Ø!ØØØØØØØØØØ)Iñð ñð r    rX   )%Ú
__future__r   r$   Úcollections.abcr   r   r;   r7   ÚloggingÚtypesr   Útypingr   r   r	   rÐ   rˆ   Ú r   r   r   r   Ú	getLoggerr(   rñ   Ú	LifoQueuer   r  r/   Ú_ConnectionProxyrU   rf   rº   rC  r4   r×   rt  ri   r    r   Ú<module>r~     sá   ðõ #ã ß /Û Û Û Ý ß &Ñ &Û Û å Ý Ý Ý ð 
ˆ×	Ñ	˜8Ó	$€ô! ×!2Ñ!2ô !ô$/˜dô /ôdO˜*×5Ñ5Ø$;Ø#õO÷Dl+ñ l+÷^]ñ ]÷@<ñ <ð@|ØØØØ!Ø16ØØØØØØ!+×!6Ñ!6Ø%Ÿ_™_õ|r    