+
    8iE                       ^ RI Ht ^ RIt^ RIt^ RIt^ RIt^ RIt^ RIt^ RIt^ RI	t	^ RI
t
^ RIt^ RIHtHtHtHtHtHtHtHtHt ^ RIHt ^ RIHtHt ^ RIHt ^ RIHt ^ RIH t  ^ R	I!H"t"H#t#H$t$H%t%H&t& ^ R
I'H(t(H)t)H*t*H+t+H,t,H-t-H.t.H/t/H0t0H1t1H2t2 ^ RI3H4t4H5t5 ^ RI6H7t7H8t8 ^ RI9H:t:H;t;H<t< ^ RI=H>t>H?t?H@t@HAtA ^ RIBHCtCHDtD ^ RIEHFtFHGtGHHtH ^ RIIHJtJ ^ RIKHLtLHMtMHNtNHOtO ^ RIPHQtQ ^ RIRHStS ^ RITHUtU ^ RIVHWtW ]'       dM   ^ RIHXtX ^ RIYHZtZ ^ RI[H\t\ ^ RIH]t] ^ RI^H_t_H`t` ^ RIaHbtbHctcHdtd ^ RIeHftfHgtg ^ RIhHiti ^ RIPHjtj ^ R IkHltlHmtm ^ R!InHoto R"tp ! R# R$4      tq ! R% R&]04      tr ! R' R(4      ts ! R) R*4      tt ! R+ R,4      tuR# )-    )annotationsN)	TYPE_CHECKINGAnyAsyncGeneratorMappingMutableMappingNoReturnOptionalSequenceUnion)DEFAULT_CODEC_OPTIONS)_csothelpers_shared)_validate_session_write_concern)_handle_reauth)command)MAX_BSON_SIZEMAX_MESSAGE_SIZEMAX_WIRE_VERSIONMAX_WRITE_BATCH_SIZEORDERED_TYPES)AutoReconnectConfigurationErrorDocumentTooLargeExecutionTimeoutInvalidOperationNetworkTimeoutNotPrimaryErrorOperationFailurePyMongoErrorWaitQueueTimeoutError_CertificateError)HelloHelloCompat)_get_timeout_detailsformat_timeout_details)_async_cond_wait_async_create_condition_async_create_lock)_CONNECTION_LOGGER_ConnectionStatusMessage
_debug_log _verbose_connection_error_reason)ConnectionCheckOutFailedReasonConnectionClosedReason)AsyncNetworkingInterfaceasync_receive_messageasync_sendall)PoolOptions)	SSLErrors_CancellationContext_configured_protocol_interface_raise_connection_failure)ReadPreference)_add_to_command)SERVER_TYPE)SocketChecker)CodecOptions)ObjectId)_AuthContext)AsyncClientSession)AsyncMongoClient_MongoClientErrorHandler)SnappyContextZlibContextZstdContext)_OpMsg_OpReply)ReadConcern)_ServerMode)_Address_CollationIn)WriteConcernFc                     ] tR t^stRtR R ltR R ltR R ltR R	 ltR
 R lt	R R lt
R R ltR R ltR R ltR R lt]]P"                  ]RRRRRRRRRRRR3R R ll4       tR R ltR R ltR R  ltR! R" ltR# R$ ltRDR% R& lltR' R( ltR) R* ltR+ R, ltR- R. ltR/ R0 ltR1 R2 ltR3 R4 lt R5 R6 lt!R7 R8 lt"R9 R: lt#R; R< lt$R= R> lt%R? R@ lt&RA RB lt'RCt(R# )EAsyncConnectiona  Store a connection with some metadata.

:param conn: a raw connection object
:param pool: a Pool instance
:param address: the server's (host, port)
:param id: the id of this socket in it's pool
:param is_sdam: SDAM connections do not call hello on creation
c          
     ,    V ^8  d   QhRRRRRRRRR	R
/# )   connr0   poolPooladdressztuple[str, int]idintis_sdambool )formats   "W/var/www/html/photoedit/myenv/lib/python3.14/site-packages/pymongo/asynchronous/pool.py__annotate__AsyncConnection.__annotate__}   s<     9" 9"&9" 9" !	9"
 9" 9"    c                	
   \         P                  ! V4      V n        Wn        W0n        W@n        WPn        R V n        \        P                  ! 4       V n
        R V n        R V n        \        V n        \        V n        \"        V n        \&        V n        R V n        R V n        R V n        R V n        VP2                  P4                  V n        VP8                  V n        VP:                  V n        VP2                  P<                  V n        RV n         \C        4       V n"        RV n#        RV n$        RV n%        VPL                  V n'        V PN                  PQ                  4       V n)        R V n*        \W        4       V n,        VP2                  V n        R V n-        RV n.        RV n/        R V n0        R V n1        R V n2        V P2                  Pf                  V n4        RV n5        VPl                  V n6        \        P                  ! 4       V n7        RV n8        R# )FNg        )9weakrefrefpool_refrP   rS   rT   rV   closedtime	monotoniclast_checkin_timeperformed_handshakeis_writabler   max_wire_versionr   max_bson_sizer   max_message_sizer   max_write_batch_sizesupports_sessionshello_ok	is_mongosop_msg_enabledopts_event_listeners	listenersenabled_for_cmapenabled_for_logging_compression_settingscompression_settingscompression_contextr;   socket_checkeroidc_token_gen_idnegotiated_mechsauth_ctxgenpool_genget_overall
generationreadyr5   cancel_contextmore_to_come
service_idserver_connection_id
pinned_txnpinned_cursoractivesocket_timeoutlast_timeoutconnect_rtt
_client_idcreation_time_cluster_time)selfrP   rQ   rS   rT   rV   s   &&&&&&rZ   __init__AsyncConnection.__init__}   s     D)	!%!1#( !& 0* 0$8!!&##33 $ 5 5#'#;#; $(II$C$C!Y] -:_045904 --335
4H4JII	"'.237!  " II44//!^^-!r]   c                    V ^8  d   QhRRRR/# )rO   timeoutOptional[float]returnNonerX   )rY   s   "rZ   r[   r\      s     / / /D /r]   c                    WP                   8X  d   R# Wn         V P                  P                  P                  V4       R# )z?Cache last timeout to avoid duplicate calls to conn.settimeout.N)r   rP   get_conn
settimeout)r   r   s   &&rZ   set_conn_timeout AsyncConnection.set_conn_timeout   s/    '''#		%%g.r]   c               $    V ^8  d   QhRRRRRR/# )rO   clientzAsyncMongoClient[Any]cmdz"Optional[MutableMapping[str, Any]]r   r   rX   )rY   s   "rZ   r[   r\      s$      +2T	r]   c           
     	   \         P                  ! 4       pVf:   V P                  '       g&   V P                  V P                  P
                  4       R # \         P                  ! 4       pVf   V P                  pW4,
          pV^ 8  dL   \        V P                  4      p\        V4      pRVR RVR RV 2p\        V^2R^ RVR^2/V P                  4      hVe   \        VR,          4      VR	&   V P                  V4       V# )
Nz5operation would exceed time limit, remaining timeout:z.5fz <= network round trip time: okerrmsgcode  	maxTimeMS)r   	remainingr   r   rp   r   get_rttr   r%   r&   r   rh   rU   )	r   r   r   r   rttmax_time_mstimeout_details	formattedr   s	   &&&      rZ   apply_timeoutAsyncConnection.apply_timeout   s    //#?$$$%%dii&>&>?mmo;""Cm?2499=O.?ILWUXMYuvyz}u~~  AJ  @K  LF"q(FFB7%%	  ?";#56Cg&r]   c                   V ^8  d   QhRR/# rO   r   r   rX   )rY   s   "rZ   r[   r\      s     & & &r]   c                	<    R V n         V P                  '       d   Q hR# TN)r   r   r   s   &rZ   pin_txnAsyncConnection.pin_txn   s    %%%%%%r]   c                   V ^8  d   QhRR/# r   rX   )rY   s   "rZ   r[   r\      s     # #D #r]   c                	<    R V n         V P                  '       d   Q hR# r   )r   r   r   s   &rZ   
pin_cursorAsyncConnection.pin_cursor   s    !???""?r]   c                   V ^8  d   QhRR/# r   rX   )rY   s   "rZ   r[   r\      s     @ @T @r]   c                	   "   V P                  4       pV'       d   VP                  V 4      G R j  xL
  R # V P                  \        P                  4      G R j  xL
  R #  L/ L5iN)ra   checkin
close_connr/   STALE)r   rQ   s   & rZ   unpinAsyncConnection.unpin   sF     }},,t$$$//"8">">??? %?s!   -A#A(A#A!A#!A#c                   V ^8  d   QhRR/# rO   r   dict[str, Any]rX   )rY   s   "rZ   r[   r\      s     @ @> @r]   c                	    V P                   P                  '       g/   V P                  '       g   V P                   P                  '       d   R V n        \
        P                  ^/# \
        P                  ^RR /# )ThelloOk)rp   
server_apirm   load_balancedro   r$   CMD
LEGACY_CMDr   s   &rZ   	hello_cmdAsyncConnection.hello_cmd   sW     994===DII4K4K4K"&DOOQ''**Ay$??r]   c                   V ^8  d   QhRR/# )rO   r   Hello[dict[str, Any]]rX   )rY   s   "rZ   r[   r\      s     - -2 -r]   c                	B   "   V P                  R R 4      G R j  xL
 #  L5ir   )_hellor   s   &rZ   helloAsyncConnection.hello   s     [[t,,,,s   c               $    V ^8  d   QhRRRRRR/# )rO   topology_versionzOptional[Any]heartbeat_frequencyOptional[int]r   r   rX   )rY   s   "rZ   r[   r\      s-     T T'T +T 
	Tr]   c                	2	  "   V P                  4       pV P                  '       * pR pRVR&   V'       dn   RV n        V P                  P                  VR&   V P                  '       d   V P                  P
                  VR&   V P                  P                  '       d   RVR&   MmVej   WR&   Vf   Q h\        VR,          4      VR	&   RpV P                  P                  '       d-   V P                  V P                  P                  V,           4       V P                  P                  pV'       d   VP                  R
8X  d:   VP                  '       d(   VP                  R,           VP                  ,           VR&   ^ RIHp VP                   P#                  W`P$                  4      pV'       d   VP'                  4       p	V	e   WR&   MRpV'       d   \(        P*                  ! 4       p
V P-                  RVR VR7      G Rj  xL
 pV'       d"   \(        P*                  ! 4       X
,
          V n        \1        WR7      pVP2                  V n        VP4                  V n        VP6                  V n        VP8                  V n        VP:                  V n        VP<                  RJ;'       d    VP>                  V n         VP<                  V n        VPB                  V n!        VPD                  \F        PH                  \F        PJ                  \F        PL                  \F        PN                  \F        PP                  39   V n)        VPD                  \F        PT                  8H  V n+        VPD                  \F        PX                  8H  V n-        V'       d>   V P                  '       d,   V P                  P]                  VP
                  4      pWn/        RV n0        VPb                  V n2        V'       d   VPf                  V n4        V'       d.   VPk                  V4       VPm                  4       '       d   Wn7        V P                  P                  '       dY   VPp                  '       g   \s        R4      hVPp                  V n8        V Pt                  Pw                  V Pp                  4      V n<        V#  EL5i)FTbackpressurer   compressionloadBalancedNtopologyVersionr   maxAwaitTimeMSDEFAULT.saslSupportedMechsauthspeculativeAuthenticateadmin)publish_eventsexhaust_allowed)	awaitablez`Driver attempted to initialize in load balancing mode, but the server does not support this mode)=r   rf   rp   metadatarv   compressorsr   rU   connect_timeoutr   _credentials	mechanismusernamesourcepymongo.asynchronousr   r>   from_credentialsrS   speculate_commandrc   rd   r   r   r#   rg   rh   ri   rj   rk   logical_session_timeout_minutesis_readablerl   rm   server_typer:   	RSPrimaryRSSecondary	RSArbiterRSOtherRSGhostis_repl
Standaloneis_standaloneMongosrn   get_compression_contextrw   ro   connection_idr   sasl_supported_mechsrz   parse_responsespeculate_succeededr{   r   r   r}   getr   )r   r   r   r   performing_handshaker   credsr   r{   speculative_authenticatestartdocr   ctxs   &&&           rZ   r   AsyncConnection._hello   s    
 nn#'#;#;;	"N'+D$ II..CM(((%)%>%>%J%JM"yy&&&&*N#)%5!"&222$'(;d(B$CC !Iyy(((%%dii&?&?BU&UV		&&)+,1LL3,>,O()1((99%NH+3+E+E+G(+75M12HNN$ELL#eU^L__#~~/%7Dc/ ,, % 6 6"00 % 6 6$)$>$>!11=SS%BSBS 	 ?D>c>c,((!!##!!-
 
 #..+2H2HH**k.@.@@D$=$=$=++CCEDUDUVC'*$"$)$7$7!$)$>$>D!##E*++-- (99"""###(A  $..DO"mm//@DOW `sl   A"R%4RBR+"RA<R-R8R9RBRCR;RA
RR1&R!R:RA	Rc                   V ^8  d   QhRR/# r   rX   )rY   s   "rZ   r[   r\   O  s      > r]   c                	   "   V P                  R 4      G R j  xL
 pVP                  V n        VP                  4       pV^ ,          p\        P                  ! W0P
                  4       V#  LP5ir   )receive_messager   unpack_responser   _check_command_responserh   )r   replyunpacked_docsresponse_docs   &   rZ   _next_replyAsyncConnection._next_replyO  s]     **400!..--/$Q'..|=R=RS 1s   A*A(AA*TNFc          "     \    V ^8  d   QhRRRRRRRRR	R
RRRRRRRR
RRRRRRRR
RR
RRRR
RR/# )rO   dbnamestrspecMutableMapping[str, Any]read_preferencerH   codec_optionsCodecOptions[Mapping[str, Any]]checkrW   allowable_errorsz#Optional[Sequence[Union[str, int]]]read_concernzOptional[ReadConcern]write_concernzOptional[WriteConcern]parse_write_concern_error	collationzOptional[_CollationIn]sessionOptional[AsyncClientSession]r   Optional[AsyncMongoClient[Any]]retryable_writer   user_fieldszOptional[Mapping[str, Any]]r   r   r   rX   )rY   s   "rZ   r[   r\   X  s     W8 W8W8 'W8 %	W8
 7W8 W8 >W8 ,W8 .W8 $(W8 *W8 .W8 0W8 W8 W8  1!W8" #W8$ 
%W8r]   c                F  "   V P                  W4       \        W4      p\        V\        4      '       g   \	        V4      pVe"   VP
                  '       g   V
e   \        R4      hV P                  V4       V'       d   VP                  W-W04       V P                  W+V4       V'       d   V P                  MRp\        T;'       d    VP
                  '       * 4      pV P                  '       d   V P                  V4        \        V VVV P                  VVVVVVV P                   VV P"                  VV	V
V P$                  V P                  VVVVR7      G Rj  xL
 #  L  \&        \(        3 d    h \*         d&   pT P-                  T4      G Rj  xL 
   Rp?R# Rp?ii ; i5i)a  Execute a command or raise an error.

:param dbname: name of the database on which to run the command
:param spec: a command document as a dict, SON, or mapping object
:param read_preference: a read preference
:param codec_options: a CodecOptions instance
:param check: raise OperationFailure if there are errors
:param allowable_errors: errors to ignore if `check` is True
:param read_concern: The read concern for this command.
:param write_concern: The write concern for this command.
:param parse_write_concern_error: Whether to parse the
    ``writeConcernError`` field in the command response.
:param collation: The collation for this command.
:param session: optional AsyncClientSession instance.
:param client: optional AsyncMongoClient for gossipping $clusterTime.
:param retryable_write: True if this command is a retryable write.
:param publish_events: Should we publish events for this command?
:param user_fields: Response fields that should be decoded
    using the TypeDecoders from codec_options, passed to
    bson._decode_all_selective.
Nz3Collation is unsupported for unacknowledged writes.)r  r  compression_ctx
use_op_msgunacknowledgedr$  r   r  )validate_sessionr   
isinstancer   dictacknowledgedr   add_server_api	_apply_tosend_cluster_timerr   rW   ro   _raise_if_not_writabler   rn   rS   ri   rw   r   r   BaseExceptionr7   )r   r  r  r  r  r  r  r  r  r  r  r   r   r#  r   r$  r   rr   r(  errors   &&&&&&&&&&&&&&&&&   rZ   r   AsyncConnection.commandW  sz    R 	f.1'I $..:D%)C)C)CyGX$%Z[[D!d_Ktf5&4DNN$	mNNM4N4N0NO''7	8  ""*C# $ 8 8..-' /+-   0 !/2 	 	800777	8sn   AF!'F!>AF!'F!.F! AE EE F!E F8F9FFFF!FF!c               $    V ^8  d   QhRRRRRR/# )rO   messagebytesmax_doc_sizerU   r   r   rX   )rY   s   "rZ   r[   r\     s!     8 8% 8s 8t 8r]   c                @  "   V P                   e.   W P                   8  d   \        RW P                   3,          4      h \        V P                  P                  V4      G Rj  xL
  R#  L  \
         d&   pT P                  T4      G Rj  xL 
   Rp?R# Rp?ii ; i5i)zmSend a raw BSON message or raise ConnectionFailure.

If a network exception is raised, the socket is closed.
NzfBSON document too large (%d bytes) - the connected server supports BSON document sizes up to %d bytes.)ri   r   r2   rP   r   r1  r7   )r   r5  r7  r2  s   &&& rZ   send_messageAsyncConnection.send_message  s     
 )l=O=O.O"?BNPbPbAcd 
	8		 2 2G<<< 	800777	8sL   <B#A+ "A)#A+ 'B)A+ +B6B
BBBBBc                    V ^8  d   QhRRRR/# )rO   
request_idr   r   zUnion[_OpReply, _OpMsg]rX   )rY   s   "rZ   r[   r\     s     	8 	8 	8BY 	8r]   c                   "    \        WV P                  4      G Rj  xL
 #  L  \         d&   pT P                  T4      G Rj  xL 
   Rp?R# Rp?ii ; i5i)zjReceive a raw BSON message or raise ConnectionFailure.

If any exception is raised, the socket is closed.
N)r1   rj   r1  r7   )r   r<  r2  s   && rZ   r
  AsyncConnection.receive_message  sF     
	8.tAVAVWWWW 	800777	8sB   A$ "$ A$ AAAA	AAAc                    V ^8  d   QhRRRR/# )rO   r(  rW   r   r   rX   )rY   s   "rZ   r[   r\     s     d dT dd dr]   c           	     b    V'       d'   V P                   '       g   \        RR^ RRRR/4      hR# R# )zNRaise NotPrimaryError on unacknowledged write if this socket is not
writable.
znot primaryr   r   r   i{'  N)rg   r   )r   r(  s   &&rZ   r0  &AsyncConnection._raise_if_not_writable  s5     $"2"2"2!-$8]TZ\a1bcc #3>r]   c               $    V ^8  d   QhRRRRRR/# )rO   msgr6  r7  rU   r   r   rX   )rY   s   "rZ   r[   r\     s!     	3 	3U 	3# 	3$ 	3r]   c                f   "   V P                  R4       V P                  W4      G Rj  xL
  R#  L5i)zSend unack OP_MSG.

Can raise ConnectionFailure or InvalidDocument.

:param msg: bytes, an OP_MSG message.
:param max_doc_size: size in bytes of the largest document in `msg`.
TN)r0  r9  )r   rC  r7  s   &&&rZ   unack_writeAsyncConnection.unack_write  s)      	##D)222s   &1/1c               (    V ^8  d   QhRRRRRRRR/# )	rO   r<  rU   rC  r6  r  r  r   r   rX   )rY   s   "rZ   r[   r\     s,      $):Y	r]   c                   "   V P                  V^ 4      G Rj  xL
  V P                  V4      G Rj  xL
 pVP                  V4      p\        P                  ! WPP
                  4       V#  LP L95i)zSend "insert" etc. command, returning response as a dict.

Can raise ConnectionFailure or OperationFailure.

:param request_id: an int.
:param msg: bytes, the command message.
N)r9  r
  command_responser   r  rh   )r   r<  rC  r  r  results   &&&&  rZ   write_commandAsyncConnection.write_command  sc      Q'''**:66''6 	..v7L7LM 	(6s   A-A)A-A+8A-+A-c                    V ^8  d   QhRRRR/# )rO   reauthenticaterW   r   r   rX   )rY   s   "rZ   r[   r\     s          $  r]   c           
     @  "   V'       d!   V P                   '       d   RV n        RV n        V P                  '       Eg\   V P                  P                  pV'       d"   ^ RIHp VP                  W VR7      G Rj  xL
  RV n        \        P                  ! 4       V P                  ,
          pV P                  '       dB   V P                  f   Q hV P                  P                  V P                  V P                  V4       V P                   '       d   \"        P$                  ! \&        P(                  4      '       d]   \+        \"        \,        P.                  V P0                  V P                  ^ ,          V P                  ^,          V P                  VR7       R# R# R# R#  EL#5i)zXAuthenticate to the server if needed.

Can raise ConnectionFailure or OperationFailure.
NFr   )rN  Tr5  clientId
serverHost
serverPortdriverConnectionId
durationMS)rf   r{   r   rp   r   r   r   authenticaterc   rd   r   rs   rr   publish_connection_readyrS   rT   rt   r*   isEnabledForloggingDEBUGr,   r+   
CONN_READYr   )r   rN  r  r   durations   &&   rZ   rV  AsyncConnection.authenticate  s#     ''' $DJzzzII**E5''N'SSSDJ~~'$*<*<<H$$$~~11177dggxX''',>,K,KGMM,Z,Z&4??!__#||A#||A'+ww' -[' 
 Ts6   F FFF8F9AF<AF)F9A#Fc               $    V ^8  d   QhRRRRRR/# )rO   r   r"  r   r!  r   r   rX   )rY   s   "rZ   r[   r\     s$      5@\	r]   c                P    V'       d   VP                   VJd   \        R4      hR# R# )zsValidate this session before use with client.

Raises error if the client is not the one that created the session.
z>Can only use session with the AsyncMongoClient that started itN)_clientr   )r   r   r   s   &&&rZ   r)   AsyncConnection.validate_session  s-     f,&T  - r]   c                    V ^8  d   QhRRRR/# )rO   reasonzOptional[str]r   r   rX   )rY   s   "rZ   r[   r\   !  s      }  r]   c                n  "   V P                   '       d   R# V P                  4       G Rj  xL
  V'       d   V P                  '       dB   V P                  f   Q hV P                  P	                  V P
                  V P                  V4       V P                  '       d   \        P                  ! \        P                  4      '       dg   \        \        \        P                  V P                  V P
                  ^ ,          V P
                  ^,          V P                  \!        V4      VR7       R# R# R# R#  EL5i)z$Close this connection with a reason.Nr5  rQ  rR  rS  rT  rc  r2  )rb   _close_connrs   rr   publish_connection_closedrS   rT   rt   r*   rX  rY  rZ  r,   r+   CONN_CLOSEDr   r-   )r   rc  s   &&rZ   r   AsyncConnection.close_conn!  s     ;;;   $$$~~11188twwPVW''',>,K,KGMM,Z,Z&4@@!__#||A#||A'+ww;FC 	 -['	  	!s(   (D5D2D5D5	AD5)D5A-D5c                   V ^8  d   QhRR/# r   rX   )rY   s   "rZ   r[   r\   6  s      4 r]   c                   "   V P                   '       d   R# RV n         V P                  P                  4         V P                  P	                  4       G Rj  xL
  R#  L  \
         d     R# i ; i5i)zClose this connection.NT)rb   r   cancelrP   close	Exceptionr   s   &rZ   rf  AsyncConnection._close_conn6  sT     ;;;""$	))//### 		s:   6A1A AA A1A A.*A1-A..A1c                   V ^8  d   QhRR/# rO   r   rW   rX   )rY   s   "rZ   r[   r\   C  s     * *T *r]   c                    \         '       d0   V P                  P                  V P                  P                  4      # V P                  P                  4       # )z?Return True if we know socket has been closed, False otherwise.)_IS_SYNCrx   socket_closedrP   r   
is_closingr   s   &rZ   conn_closedAsyncConnection.conn_closedC  s;    8&&44TYY5G5GHH99''))r]   c               (    V ^8  d   QhRRRRRRRR/# )	rO   r   r  r   r!  r   r"  r   r   rX   )rY   s   "rZ   r[   r\   J  s2     8 8)8 .8 0	8
 
8r]   c                <    V'       d   VP                  W4       R# R# )zAdd $clusterTime.N)_send_cluster_time)r   r   r   r   s   &&&&rZ   r/  !AsyncConnection.send_cluster_timeJ  s     %%g7 r]   c                    V ^8  d   QhRRRR/# )rO   r   r  r   r   rX   )rY   s   "rZ   r[   r\   T  s     ; ;&> ;4 ;r]   c                    V P                   P                  '       d"   \        WP                   P                  4       R# R# )zAdd server_api parameters.N)rp   r   r9   )r   r   s   &&rZ   r-  AsyncConnection.add_server_apiT  s)    99GYY%9%9:  r]   c                   V ^8  d   QhRR/# r   rX   )rY   s   "rZ   r[   r\   Y  s     2 2$ 2r]   c                	:    \         P                  ! 4       V n        R # r   rc   rd   re   r   s   &rZ   update_last_checkin_time(AsyncConnection.update_last_checkin_timeY  s    !%!1r]   c                    V ^8  d   QhRRRR/# )rO   rg   rW   r   r   rX   )rY   s   "rZ   r[   r\   \  s     ' 'd 't 'r]   c                	    Wn         R # r   )rg   )r   rg   s   &&rZ   update_is_writable"AsyncConnection.update_is_writable\  s    &r]   c                   V ^8  d   QhRR/# )rO   r   floatrX   )rY   s   "rZ   r[   r\   _  s     9 95 9r]   c                N    \         P                  ! 4       V P                  ,
          # )z9Seconds since this socket was last checked into its pool.r  r   s   &rZ   idle_time_seconds!AsyncConnection.idle_time_seconds_  s    ~~$"8"888r]   c                    V ^8  d   QhRRRR/# )rO   r2  r1  r   r	   rX   )rY   s   "rZ   r[   r\   c  s      ] x r]   c                	.  "   V P                   '       d   R pM\        P                  pV P                  V4      G R j  xL
  \	        V\
        \        .\        O54      '       d/   \        V P                  4      p\        V P                  WR7       R # h  LV5i)Nr   )r   r/   ERRORr   r*  IOErrorOSErrorr4   r%   rp   r7   rS   )r   r2  rc  detailss   &&  rZ   r7   )AsyncConnection._raise_connection_failurec  sm       :::F+11Foof%%%egw;;<<*4995G%dllES 	&s   :BBABc                    V ^8  d   QhRRRR/# rO   otherr   r   rW   rX   )rY   s   "rZ   r[   r\     s     ' 'C 'D 'r]   c                	4    V P                   VP                   8H  # r   )rP   r   r  s   &&rZ   __eq__AsyncConnection.__eq__  s    yyEJJ&&r]   c                    V ^8  d   QhRRRR/# r  rX   )rY   s   "rZ   r[   r\     s     ! !C !D !r]   c                	    W8X  * # r   rX   r  s   &&rZ   __ne__AsyncConnection.__ne__  s      r]   c                   V ^8  d   QhRR/# rO   r   rU   rX   )rY   s   "rZ   r[   r\     s      # r]   c                	,    \        V P                  4      # r   )hashrP   r   s   &rZ   __hash__AsyncConnection.__hash__  s    DIIr]   c                   V ^8  d   QhRR/# )rO   r   r  rX   )rY   s   "rZ   r[   r\     s     
 
# 
r]   c                	    R P                  \        V P                  4      V P                  ;'       d    R;'       g    R\	        V 4      4      # )zAsyncConnection({}){} at {}z CLOSED )rY   reprrP   rb   rT   r   s   &rZ   __repr__AsyncConnection.__repr__  s>    ,33OKK%%I++tH
 	
r]   )-r   r   r   rS   r{   r   rb   rw   rv   rP   r   r   rs   rt   r   rm   rT   rn   r   rV   r   rg   re   r   rr   r   ri   rj   rh   rk   r   rz   ry   ro   rp   rf   r   r   r}   ra   r   r   r   rx   rl   )F))__name__
__module____qualname____firstlineno____doc__r   r   r   r   r   r   r   r   r   r  r   r8   PRIMARYr   r   r9  r
  r0  rE  rK  rV  r)  r   rf  rv  r/  r-  r  r  r  r7   r  r  r  r  __static_attributes__rX   r]   rZ   rM   rM   s   s    9"v/>&#@@-Tl 
 (6'='=9N@D.204*/,00426 %#37 %#W8 W8r8"	8d	3$ D**8;
2'98'!
 
r]   rM   c                      ] tR tRtRtRtR# )_PoolClosedErrori  zRInternal error raised when a thread tries to get a connection from a
closed pool.
rX   N)r  r  r  r  r  r  rX   r]   rZ   r  r    s    r]   r  c                  R    ] tR tRtR R ltR R ltR R ltR R	 ltR
 R ltRt	R# )_PoolGenerationi  c                   V ^8  d   QhRR/# r   rX   )rY   s   "rZ   r[   _PoolGeneration.__annotate__  s      $ r]   c                	R    \         P                  ! \        4      V n        ^ V n        R# )r   N)collectionsdefaultdictrU   _generations_generationr   s   &rZ   r   _PoolGeneration.__init__  s    1<1H1H1Mr]   c                    V ^8  d   QhRRRR/# )rO   r   Optional[ObjectId]r   rU   rX   )rY   s   "rZ   r[   r    s     - -0 -S -r]   c                H    Vf   V P                   # V P                  V,          # )z,Get the generation for the given service_id.r  r  r   r   s   &&rZ   r   _PoolGeneration.get  s%    ###  ,,r]   c                   V ^8  d   QhRR/# r  rX   )rY   s   "rZ   r[   r    s        S  r]   c                    V P                   # )z"Get the Pool's overall generation.)r  r   s   &rZ   r~   _PoolGeneration.get_overall  s    r]   c                    V ^8  d   QhRRRR/# )rO   r   r  r   r   rX   )rY   s   "rZ   r[   r    s     / /0 /T /r]   c                    V ;P                   ^,          un         Vf5   V P                   F"  pV P                  V;;,          ^,          uu&   K$  	  R# V P                  V;;,          ^,          uu&   R# )z2Increment the generation for the given service_id.Nr  r  s   &&rZ   inc_PoolGeneration.inc  sW    A"//
!!*-2- 0 j)Q.)r]   c               $    V ^8  d   QhRRRRRR/# rO   r|   rU   r   r  r   rW   rX   )rY   s   "rZ   r[   r    s"     + + +*< + +r]   c                (    WP                  V4      8g  # )z?Return if the given generation for a given service_id is stale.)r   r   r|   r   s   &&&rZ   stale_PoolGeneration.stale  s    hhz***r]   r  N)
r  r  r  r  r   r   r~   r  r  r  rX   r]   rZ   r  r    s     - /+ +r]   r  c                  "    ] tR tRt^t^t^tRtR# )	PoolStatei  rX   N)r  r  r  r  PAUSEDREADYCLOSEDr  rX   r]   rZ   r  r    s    FEFr]   r  c                  :   ] tR tRtR*R R lltR R lt]R R l4       tR+R	 R
 lltR R lt	R,R R llt
R R ltR R ltR R ltR R ltR R ltR-R R llt]P$                  R-R R ll4       tR R ltR-R R  lltR! R" ltR# R$ ltR% R& ltR' R( ltR)tR# ).rR   i  Nc               (    V ^8  d   QhRRRRRRRR/# )	rO   rS   rI   optionsr3   rV   rW   	client_idr  rX   )rY   s   "rZ   r[   Pool.__annotate__  s8     T TT T 	T
 &Tr]   c                f   VP                   '       d   \        P                  V n        M\        P                  V n        ^V n        \        P                  ! 4       V n        \        4       V n
        \        4       V n        \        V P                  4      V n        ^ V n        ^V n        RV n        \%        4       V n        \(        P*                  ! 4       V n        Wn        W n        W0n        V P2                  '       * ;'       dA    V P0                  P4                  RJ;'       d!    V P0                  P4                  P6                  V n        V P2                  '       * V n        \        V P                  4      V n        ^ V n        V P0                  P>                  V n        V P>                  '       g   \A        R4      V n        \        V P                  4      V n        ^ V n!        V P0                  PD                  V n#        W@n$        V P6                  '       d_   V P0                  P4                  f   Q hV P0                  P4                  PK                  V P.                  V P0                  PL                  4       V P8                  '       d   \N        PP                  ! \R        PT                  4      '       dg   \W        \N        3R\X        PZ                  RV PH                  RV P.                  ^ ,          RV P.                  ^,          /V P0                  PL                  B  ^ V n.        \        4       V n/        ^ V n0        ^ V n1        R# )z
:param address: a (hostname, port) tuple
:param options: a PoolOptions instance
:param is_sdam: whether to call hello for each new AsyncConnection
Ninfr5  rQ  rR  rS  )2pause_enabledr  r  stater  _check_interval_secondsr  dequeconnssetactive_contextsr)   lockr(   _max_connecting_condactive_socketsnext_connection_idrg   r  r|   osgetpidpidrS   rp   rV   rq   rs   rt   	size_condrequestsmax_pool_sizer  _pendingmax_connecting_max_connectingr   publish_pool_creatednon_default_optionsr*   rX  rY  rZ  r,   r+   POOL_CREATEDoperation_count_Pool__pinned_socketsncursorsntxns)r   rS   r  rV   r  s   &&&&&rZ   r   Pool.__init__  so       "))DJ"DJ ()$ :E9J9J9L
:=%&(	$;DII$F!"#+/
 #$99;	  < <		**$6< <		**;; 	
 (,||#3 
 1;!YY44!!!!&uD %<DII$F!#yy77#   99--999II&&;;dii;; ###(:(G(G(V(V"0==   <<?	
  <<? ))// %& 7:e
r]   c                   V ^8  d   QhRR/# r   rX   )rY   s   "rZ   r[   r    s      T r]   c           
     	  "   V P                   ;_uu_4       GR j  xL
  V P                  \        P                  8w  d   \        P                  V n        V P                  '       dJ   V P
                  P                  f   Q hV P
                  P                  P                  V P                  4       V P                  '       dy   \        P                  ! \        P                  4      '       dO   \        \        \        P                   V P"                  V P                  ^ ,          V P                  ^,          R7       R R R 4      GR j  xL
  R #  EL0 L	  + GR j  xL 
 '       g   i     R # ; i5i)Nr5  rQ  rR  rS  )r  r  r  r  rs   rp   rq   publish_pool_readyrS   rt   r*   rX  rY  rZ  r,   r+   
POOL_READYr   r   s   &rZ   r   
Pool.ready  s     9999zzY__,&__
(((9955AAAII..AA$,,O+++0B0O0OPWP]P]0^0^* 8 C C!%#'<<?#'<<? 999999s_   E-EE-AE&AE)E+AE9E-EE-E-E*	E
E*	"E*	$	E-c                   V ^8  d   QhRR/# rq  rX   )rY   s   "rZ   r[   r  $  s     . . .r]   c                	<    V P                   \        P                  8H  # r   )r  r  r  r   s   &rZ   rb   Pool.closed#  s    zzY----r]   c          
     ,    V ^8  d   QhRRRRRRRRRR/# )	rO   rm  rW   pauser   r  interrupt_connectionsr   r   rX   )rY   s   "rZ   r[   r  '  sJ     [H [H[H [H '	[H
  $[H 
[Hr]   c           	     	z
  "   V P                   pV P                  ;_uu_4       GR j  xL
  V P                  '       d    R R R 4      GR j  xL
  R # V P                  P                  '       dF   V'       d>   V P                  P
                  '       g"   V P                   \        P                  uqPn         V P                  P                  V4       \        P                  ! 4       pV P                  V8w  d   W`n        ^ V n        ^ V n        Vf(   V P                  \         P"                  ! 4       uqpn        Mz\         P"                  ! 4       p\         P"                  ! 4       p	V P                   F8  p
V
P$                  V8X  d   VP'                  V
4       K'  V	P'                  V
4       K:  	  TpWn        V'       d   \        P(                  V n         V P*                  P-                  4        V P                  P-                  4        V'       d$   V P.                   F  pVP1                  4        K  	  R R R 4      GR j  xL
  V P                  P2                  pV'       EdK   \4        '       gL   \6        P8                  ! X U
u. uF!  qP;                  \<        P>                  4      NK#  	  up
RR/ G R j  xL
  M0X F*  p
V
P;                  \<        P>                  4      G R j  xL
  K,  	  V P@                  '       d"   Vf   Q hVPC                  V PD                  4       V PF                  '       d}   \H        PJ                  ! \L        PN                  4      '       dQ   \Q        \H        \R        P>                  V PT                  V PD                  ^ ,          V PD                  ^,          R7       R # R # R # V\        P                  8w  d   V P@                  '       d%   Vf   Q hVPW                  V PD                  VVR7       V PF                  '       dz   \H        PJ                  ! \L        PN                  4      '       dP   \Q        \H        \R        PX                  V PT                  V PD                  ^ ,          V PD                  ^,          VR7       \4        '       gM   \6        P8                  ! X U
u. uF!  qP;                  \<        PZ                  4      NK#  	  up
RR/ G R j  xL
  R # X F*  p
V
P;                  \<        PZ                  4      G R j  xL
  K,  	  R #  EL EL EL  + GR j  xL 
 '       g   i     EL; iu up
i  EL ELZu up
i  Ln LB5i)Nreturn_exceptionsTr  )r   r  )r5  rQ  rR  rS  	serviceId).r  r  rb   rp   r  r   r  r  r|   r  r  r  r  r  r  r  r  r  r   appendr  r  
notify_allr  rl  rq   rs  asynciogatherr   r/   POOL_CLOSEDrs   publish_pool_closedrS   rt   r*   rX  rY  rZ  r,   r+   r   publish_pool_clearedPOOL_CLEAREDr   )r   rm  r  r   r  	old_statenewpidsocketsdiscardkeeprP   contextrr   s   &&&&&        rZ   _resetPool._reset'  s     JJ	>>>>{{{ ">> yy&&&59P9P9P(,

I4D4D%	:HHLL$YY[Fxx6!!&'#'($!&*jj+2C2C2E#-8->->-@*5*;*;*= JJD*4t,D)	 '
 "!
&--
%%002NN%%'$#33GNN$  4? ">D II..	 58nnV]^V]doo&<&H&HIV]^&*  
 $D//*@*L*LMMM $$$$ ,,,--dll;''',>,K,KGMM,Z,Z&4@@!__#||A#||A -[' I,,,((($00022#-.C 3 
 +++0B0O0OPWP]P]0^0^* 8 E E!%#'<<?#'<<?", 8nnPWXPWoo&<&B&BCPWX&*  
 $D//*@*F*FGGG $e ">>>>R _ N@ Y Hs  %T;TT;T
T;
TT;T
-T
5T
D"T
4AT
#T
(T;3T4"T;T;#T;7'T'
T;(T,),T;T/T;02T;#)T;A:T;5T;>)T;(AT;T;'T2>
T;T7	-T;6T97T;T;T;
T$	T
T$	T$	T;/T;2T;9T;c                    V ^8  d   QhRRRR/# )rO   rg   zOptional[bool]r   r   rX   )rY   s   "rZ   r[   r    s     = =N =t =r]   c                  "   Wn         V P                  ;_uu_4       GRj  xL
  V P                   F  pVP                  V P                   4       K   	  RRR4      GRj  xL
  R#  LD L  + GRj  xL 
 '       g   i     R# ; i5i)zHUpdates the is_writable attribute on all sockets currently in the
Pool.
N)rg   r  r  r  )r   rg   _sockets   && rZ   r  Pool.update_is_writable  sI      '9999::**4+;+;< & 99999sJ   BA&B/A*BA( B(B*B	0A31
B	<B	>	Bc               $    V ^8  d   QhRRRRRR/# )rO   r   r  r  rW   r   r   rX   )rY   s   "rZ   r[   r    s$     
 
,
LP
	
r]   c                	H   "   V P                  R WR7      G Rj  xL
  R#  L5i)F)rm  r   r  Nr  )r   r   r  s   &&&rZ   reset
Pool.reset  s'      kkJ  
 	
 	
   " "c                   V ^8  d   QhRR/# r   rX   )rY   s   "rZ   r[   r    s     4 44 4r]   c                	H   "   V P                  R R R7      G Rj  xL
  R#  L5i)F)rm  r  Nr  r   s   &rZ   reset_without_pausePool.reset_without_pause  s     kkUk333r"  c                   V ^8  d   QhRR/# r   rX   )rY   s   "rZ   r[   r    s     & &T &r]   c                	F   "   V P                  R R7      G Rj  xL
  R#  L5i)T)rm  Nr  r   s   &rZ   rm  
Pool.close  s     kkk%%%s   !!c               $    V ^8  d   QhRRRRRR/# r  rX   )rY   s   "rZ   r[   r    s"     / /C /5G /D /r]   c                	8    V P                   P                  W4      # r   )r|   r  r  s   &&&rZ   stale_generationPool.stale_generation  s    xx~~c..r]   c                    V ^8  d   QhRRRR/# )rO   reference_generationrU   r   r   rX   )rY   s   "rZ   r[   r    s     C, C,s C,t C,r]   c           
       "   V P                   ;_uu_4       GRj  xL
  V P                  \        P                  8w  d    RRR4      GRj  xL
  R# RRR4      GRj  xL
  V P                  P
                  Ee.   . pV P                   ;_uu_4       GRj  xL
  V P                  '       df   V P                  R,          P                  4       V P                  P
                  8  d,   VP                  V P                  P                  4       4       Kw  RRR4      GRj  xL
  \        '       gL   \        P                  ! V Uu. uF!  q3P                  \        P                  4      NK#  	  upRR/ G Rj  xL
  M0V F*  pVP                  \        P                  4      G Rj  xL
  K,  	   V P                   ;_uu_4       GRj  xL
  \#        V P                  4      V P$                  ,           V P                  P&                  8  d    RRR4      GRj  xL
  R# V P(                  V P                  P&                  8  d    RRR4      GRj  xL
  R# V ;P(                  ^,          un        RRR4      GRj  xL
  Rp V P*                  ;_uu_4       GRj  xL
  V P,                  V P.                  8  d    RRR4      GRj  xL
  V'       da   V P*                  ;_uu_4       GRj  xL
  V ;P,                  ^,          un        V P*                  P1                  4        RRR4      GRj  xL
  V P                   ;_uu_4       GRj  xL
  V ;P(                  ^,          un        V P                   P1                  4        RRR4      GRj  xL
  R# V ;P,                  ^,          un        RpRRR4      GRj  xL
  V P3                  4       G Rj  xL
 pRpV P                   ;_uu_4       GRj  xL
  V P4                  P7                  4       V8w  d   RpV'       gA   V P                  P9                  V4       V P:                  P=                  VP>                  4       RRR4      GRj  xL
  V'       d   VP                  \        P@                  4      G Rj  xL
   V'       da   V P*                  ;_uu_4       GRj  xL
  V ;P,                  ^,          un        V P*                  P1                  4        RRR4      GRj  xL
  V P                   ;_uu_4       GRj  xL
  V ;P(                  ^,          un        V P                   P1                  4        RRR4      GRj  xL
  R#  V'       da   V P*                  ;_uu_4       GRj  xL
  V ;P,                  ^,          un        V P*                  P1                  4        RRR4      GRj  xL
  V P                   ;_uu_4       GRj  xL
  V ;P(                  ^,          un        V P                   P1                  4        RRR4      GRj  xL
  EK   EL EL EL  + GRj  xL 
 '       g   i     EL; i EL EL=  + GRj  xL 
 '       g   i     ELU; iu upi  EL EL EL ELv ELA EL  + GRj  xL 
 '       g   i     EL1; i EL EL EL EL  + GRj  xL 
 '       g   i     EL; i EL ELQ  + GRj  xL 
 '       g   i     R# ; i ELD  + GRj  xL 
 '       g   i     EL\; i ELL EL0 EL  + GRj  xL 
 '       g   i     EL; i EL EL ELH  + GRj  xL 
 '       g   i     EL`; i ELK EL  + GRj  xL 
 '       g   i     R# ; i EL EL  + GRj  xL 
 '       g   i     EL; i EL EL  + GRj  xL 
 '       g   i     EK$  ; i  T'       d   T P*                  ;_uu_4       GRj  xL 
  T ;P,                  ^,          un        T P*                  P1                  4        RRR4      GRj  xL 
  M  + GRj  xL 
 '       g   i     M; iT P                   ;_uu_4       GRj  xL 
  T ;P(                  ^,          un        T P                   P1                  4        RRR4      GRj  xL 
  i   + GRj  xL 
 '       g   i     i ; i; i5i)zRemoves stale sockets then adds new ones if pool is too small and
has not been reset. The `reference_generation` argument specifies the
`generation` at the point in time this operation was requested on the
pool.
Nr  TF)!r  r  r  r  rp   max_idle_time_secondsr  r  r	  poprs  r  r  r   r/   IDLEr  lenr  min_pool_sizer  r  r  r  notifyconnectr|   r~   
appendleftr  r  r   r   )r   r/  close_connsrP   incrementedr   s   &&    rZ   remove_stale_socketsPool.remove_stale_sockets  s     9999zzY__, 9999 99**6KyyyyJJJ

288:TYY=\=\\&&tzz~~'78 !y 8nnOZ[{too&<&A&AB{[&*  
 (D//*@*E*EFFF ( ~~~~tzz?T%8%88DII<S<SS &~~ ==DII$;$;; &~~ " &~  K,4444 }}(<(<<	 54* #8888*1188:  98  >>>>MMQ&MNN))+ *>>- MMQ&M"&K 54 "\\^+"
9999 xx++-1EE%)
%

--d3,,44T5H5HI %9 //*@*F*FGGG#8888*1188:  98  >>>>MMQ&MNN))+ *>>  #8888*1188:  98  >>>>MMQ&MNN))+ *>>u 9999 !yyy \ G &~~~~ 5.  9888 *>>>7 5444 ,$999 H
  9888 *>>>	  9888 *>>>> #8888*1188:  988888  >>>>MMQ&MNN))+ *>>>>>s  cX0c!X9 cX3cX67cYcY,A%YcYc-c'Y9(
c2Y>3,cZ !cZcAZcZc&Z>c	Z

cZ)c4Z5c<_ Z-_ [<5_  Z0_  c%Z3&c)4Z9c(Z6)c[c	4[=c[	c[<*_ 5[96_ \_ ,\-_ 0)\"A \"_ %\&_ 2"_ \?_  c:];c>4]2c=]>c]%c4]+c](c%c-c^c	4^=c^	c%^+&c)4^1c(^.)c3c6c9Y	?Y 
Y	Y	
ccY6	"Y%#
Y6	.Y6	0cccc
ccZ*	Z
Z*	"Z*	$	c-_ 0_ 3c6c9[	?[ 
[	[	
cc[6	"[%#
[6	.[6	0	c9_ <\	\
\	\	
_ _ _ "\<	(\+)
\<	4\<	6
_ cc]"	]
]"	]"	
c(c+^	1]42
^	=^	?
cc^(	^
^(	 ^(	"
c.c1_	7^:8
_	_	
c!c0_31c54`;	)c4`75c;aa
aa c/a20c44b:	(c3b64c:c c
ccccc                    V ^8  d   QhRRRR/# )rO   r2  r1  r   r   rX   )rY   s   "rZ   r[   r    s     1 1m 1 1r]   c                	   V P                   '       g   \        V4      \        \        39  d   R # \	        V\        4      '       g   Q h\	        VP
                  \        \        \        P                  34      '       d=   \	        VP
                  \        P                  \        P                  34      '       g   R # VP                  R4       VP                  R4       R # )NSystemOverloadedErrorRetryableError)rV   typer   r   r*  	__cause__r"   r4   socketgaierrorsslSSLEOFErrorSSLZeroReturnError_add_error_label)r   r2  s   &&rZ   _handle_connection_errorPool._handle_connection_error  s     <<<4;}n.MM%////eoo(99foo'VWW eooAWAW/XYY67/0r]   c                    V ^8  d   QhRRRR/# )rO   handler"Optional[_MongoClientErrorHandler]r   rM   rX   )rY   s   "rZ   r[   r    s      U U%G USb Ur]   c                  "   V P                   ;_uu_4       GRj  xL
  V P                  pV ;P                  ^,          un        \        4       pV P                  P	                  V4       RRR4      GRj  xL
  V P
                  P                  pV P                  '       d#   Vf   Q hVP                  V P                  X4       V P                  '       dz   \        P                  ! \        P                  4      '       dP   \        \        \         P"                  V P$                  V P                  ^ ,          V P                  ^,          XR7        \'        V P                  V P
                  4      G Rj  xL
 p\E        YPT P                  XT PF                  4      pT P                   ;_uu_4       GRj  xL
  T P                  P	                  TPH                  4       T P                  P+                  X4       RRR4      GRj  xL
  XPJ                  '       d   TPH                  PM                  4        Rp	 T PF                  '       g,   TPO                  4       G Rj  xL
  Rp	TPP                  T n(        T'       d   TPS                  TRR7       TPU                  4       G Rj  xL
  T'       d8   TPX                  PZ                  P]                  TP^                  4      G Rj  xL
  T#  EL ELu  + GRj  xL 
 '       g   i     EL; i EL  \(         Ed   pT P                   ;_uu_4       GRj  xL 
  T P                  P+                  X4       RRR4      GRj  xL 
  M  + GRj  xL 
 '       g   i     M; iT P                  '       d2   Tf   Q hTP-                  T P                  X\.        P0                  4       T P                  '       d   \        P                  ! \        P                  4      '       dw   \        \        \         P2                  T P$                  T P                  ^ ,          T P                  ^,          X\5        \.        P0                  4      \.        P0                  R7       T P7                  T4       \9        T\:        \<        .\>        O54      '       d-   \A        T P
                  4      p\C        T P                  YgR7       h Rp?ii ; i EL, EL  + GRj  xL 
 '       g   i     EL; i EL ELc  \(         d   p
T P                   ;_uu_4       GRj  xL 
  T P                  P+                  TPH                  4       RRR4      GRj  xL 
  M  + GRj  xL 
 '       g   i     M; iT	'       g   T P7                  T
4       TPW                  \.        P0                  4      G Rj  xL 
  h Rp
?
ii ; i EL5i)zConnect to Mongo and return a new AsyncConnection.

Can raise ConnectionFailure.

Note that the pool does not keep a reference to the socket -- you
must call checkin() when you're done with it.
Nr5  rQ  rR  rS  rT  re  r  FT)completed_handshake)0r  r  r5   r  addrp   rq   rs   publish_connection_createdrS   rt   r*   rX  rY  rZ  r,   r+   CONN_CREATEDr   r6   r1  r  rg  r/   r  rh  r-   rJ  r*  r  r  r4   r%   r7   rM   rV   r   	cancelledrl  r   rg   contribute_socketrV  r   r   	_topologyreceive_cluster_timer   )r   rM  conn_idtmp_contextrr   networking_interfacer2  r  rP   completed_helloes   &&         rZ   r8  Pool.connect  s     9999--G##q(#.0K  $$[1 9 II..	   (((00wG###(:(G(G(V(V"0==<<?<<?#*	)GVZV_V_)`#` 6 34<<RVR^R^_9999  $$T%8%89  ((5 9    &&(	<<<jjl"""&#'#3#3 ))$E)J##%%% ..**??@R@RSSS[ 999, $a 	yyyy$$,,[9 !yyyyy$$$ ,,,33LL'+A+G+G ''',>,K,KGMM,Z,Z&4@@!__#||A#||A'.;<R<X<XY066	 ))%0%'7!?Y!?@@.tyy9)$,,W/	4 999 # & 	yyyy$$,,T-@-@A !yyyyy"--a0//"8">">???	 Ts  WK'WAK-*W5K*6+W"3W)W AW#L 3L
4L 8:W2S3W6AS$7WS!WW6T T TT ;&T !T"T &W.2W W!W*W-L	3K64
L	?L		W
L SS1L4
2S6M$SM S$M=*M-+
M=6M=8SAS)S?CSSW!W$S>	*S-+
S>	6S>	8	WT T W
W*T-
+W/&U'W U#!W'V -U0.
V 9V ;W3W>W?WW

Wc                    V ^8  d   QhRRRR/# )rO   rM  rN  r   z%AsyncGenerator[AsyncConnection, None]rX   )rY   s   "rZ   r[   r  I  s      L% L%9L%	.L%r]   c           
      "   V P                   P                  p\        P                  ! 4       pV P                  '       d"   Vf   Q hVP                  V P                  4       V P                  '       dy   \        P                  ! \        P                  4      '       dO   \        \        \        P                  V P                  V P                  ^ ,          V P                  ^,          R7       V P!                  W1R7      G Rj  xL
 p\        P                  ! 4       V,
          pV P                  '       d.   Vf   Q hVP#                  V P                  VP$                  V4       V P                  '       d   \        P                  ! \        P                  4      '       d[   \        \        \        P&                  V P                  V P                  ^ ,          V P                  ^,          VP$                  VR7        V P(                  ;_uu_4       GRj  xL
  V P*                  P-                  VP.                  4       RRR4      GRj  xL
  V5x  TP2                  '       dd   T P(                  ;_uu_4       GRj  xL
  T P@                  P-                  T4       T ;PB                  ^,          un!        RRR4      GRj  xL
  R# TP4                  '       dd   T P(                  ;_uu_4       GRj  xL
  T P@                  P-                  T4       T ;PD                  ^,          un"        RRR4      GRj  xL
  R# TP<                  '       d   T P?                  T4      G Rj  xL
  R# R#  ELg EL[ EL)  + GRj  xL 
 '       g   i     ELA; i  \0         d    TP2                  ;'       g    TP4                  pT'       d3   \6        P8                  ! 4       w  rxp	TP;                  Yx4      G Rj  xL 
  T'       g-   TP<                  '       d   T P?                  T4      G Rj  xL 
  h i ; i EL ELr  + GRj  xL 
 '       g   i     R# ; i ELa EL   + GRj  xL 
 '       g   i     R# ; i EL5i)a  Get a connection from the pool. Use with a "with" statement.

Returns a :class:`AsyncConnection` object wrapping a connected
:class:`socket.socket`.

This method should always be used in a with-statement::

    with pool.get_conn() as connection:
        connection.send_message(msg)
        data = connection.receive_message(op_code, request_id)

Can raise ConnectionFailure or OperationFailure.

:param handler: A _MongoClientErrorHandler.
Nr  rM  rP  )#rp   rq   rc   rd   rs   $publish_connection_check_out_startedrS   rt   r*   rX  rY  rZ  r,   r+   CHECKOUT_STARTEDr   	_get_connpublish_connection_checked_outrT   CHECKOUT_SUCCEEDEDr  r  rR  r   r1  r   r   sysexc_infohandler   r   r  r  r  )
r   rM  rr   checkout_started_timerP   r\  pinnedexc_typeexc_val_s
   &&        rZ   checkoutPool.checkoutH  s    & II..	 $ 0   (((::4<<H###(:(G(G(V(V"0AA<<?<<? ^^$9^KK>>#&;;   (((44T\\477HU###(:(G(G(V(V"0CC<<?<<?#'77#	yyyy$$(()<)<= !yJ  ???yyyy%%))$/

a
 !yy yyyy%%))$/" !yy [[[,,t$$$ W L" !yyy  	
 __::(:(:F (+||~$1nnX777dkkkll4(((	 !yyy !yyy %sv  A0Q43)Q4A#Q4 M'1Q43>Q42)Q4AQ47N M*N &M09N M-	N Q4 Q48P+9Q4<5P11Q4<P.=Q4Q4-Q.Q415Q&Q41Q2Q4
Q4Q1	Q4*N -N 0N
	6M97
N
	N
		N P(+P( ,P(,O/-P(:P(P( P#!P((Q4.Q41Q	7P:8
Q	Q	
Q4Q4Q.	Q
Q.	&Q.	(
Q4c               $    V ^8  d   QhRRRRRR/# )rO   rj  r  
emit_eventrW   r   r   rX   )rY   s   "rZ   r[   r    s"       D UY r]   c                	   V P                   \        P                  8w  Edd   V'       Ed#   \        P                  ! 4       V,
          pV P
                  '       dZ   V P                  P                  f   Q hV P                  P                  P                  V P                  \        P                  V4       V P                  '       d   \        P                  ! \        P                   4      '       d`   \#        \        \$        P&                  V P(                  V P                  ^ ,          V P                  ^,          R\        P                  VR7       \+        V P                  4      p\-        V P                  \/        R4      VR7       R # R # )N<An error occurred while trying to establish a new connectionr5  rQ  rR  rS  rc  r2  rU  zconnection pool pausedr  )r  r  r  rc   rd   rs   rp   rq   #publish_connection_check_out_failedrS   r.   
CONN_ERRORrt   r*   rX  rY  rZ  r,   r+   CHECKOUT_FAILEDr   r%   r7   r   )r   rj  rr  r\  r  s   &&&  rZ   _raise_if_not_readyPool._raise_if_not_ready  s   ::(z>>+.CC(((9955AAAII..RR&D&O&OQY +++0B0O0OPWP]P]0^0^* 8 H H!%#'<<?#'<<?]<GG#+	 +4995G%m,DEW^+ )r]   c               $    V ^8  d   QhRRRRRR/# )rO   rj  r  rM  rN  r   rM   rX   )rY   s   "rZ   r[   r    s)      %*5W	r]   c                H  "   V P                   \        P                  ! 4       8w  d   V P                  4       G Rj  xL
  V P                  '       Ed.   \
        P                  ! 4       V,
          pV P                  '       dZ   V P                  P                  f   Q hV P                  P                  P                  V P                  \        P                  V4       V P                  '       d   \        P                   ! \"        P$                  4      '       d`   \'        \        \(        P*                  V P,                  V P                  ^ ,          V P                  ^,          R\        P                  VR7       \/        R4      hV P0                  ;_uu_4       GRj  xL
  V ;P2                  ^,          un        RRR4      GRj  xL
  \4        P6                  ! 4       '       d   \4        P8                  ! 4       pMOV P                  P:                  '       d2   \
        P                  ! 4       V P                  P:                  ,           pMRpV P<                  ;_uu_4       GRj  xL
  V P?                  VRR7       V P@                  V PB                  8  g   V'       d   V\
        P                  ! 4       ,
          MRp\E        V P<                  V4      G Rj  xL
 '       gG   V P@                  V PB                  8  d   V P<                  PG                  4        V PI                  V4       V P?                  VRR7       K  V ;P@                  ^,          un         RRR4      GRj  xL
  RpRpRp V P0                  ;_uu_4       GRj  xL
  V ;PJ                  ^,          un%        RpRRR4      GRj  xL
  VEf   V PL                  ;_uu_4       GRj  xL
  V P?                  VRR7       V PN                  '       g   V PP                  V PR                  8  g   V'       d   V\
        P                  ! 4       ,
          MRp\E        V PL                  V4      G Rj  xL
 '       g[   V PN                  '       g   V PP                  V PR                  8  d   V PL                  PG                  4        RpV PI                  V4       V P?                  VRR7       K   V PN                  PU                  4       pRRR4      GRj  xL
  V'       d(   V PY                  V4      G Rj  xL
 '       d   RpEKr  EKu   V P[                  VR7      G Rj  xL
 pV PL                  ;_uu_4       GRj  xL
  V ;PP                  ^,          un(        V PL                  PG                  4        RRR4      GRj  xL
  EK   RTn3        T#  ELp EL EL  + GRj  xL 
 '       g   i     EL; i ELs EL EL}  + GRj  xL 
 '       g   i     EL; i ELy ELQ  + GRj  xL 
 '       g   i     ELi; i ELO EL  \V         d    T ;PP                  ^,          un(         ELci ; i EL\  + GRj  xL 
 '       g   i     ELt; i EL[ EL5 EL L  + GRj  xL 
 '       g   i     EK  ; i  T PL                  ;_uu_4       GRj  xL 
  T ;PP                  ^,          un(        T PL                  PG                  4        RRR4      GRj  xL 
  i   + GRj  xL 
 '       g   i     i ; i; i  \\         Ed    T'       d)   TP_                  \`        Pb                  4      G Rj  xL 
  T P<                  ;_uu_4       GRj  xL 
  T ;P@                  ^,          un         T'       d   T ;PJ                  ^,          un%        T P<                  PG                  4        RRR4      GRj  xL 
  M  + GRj  xL 
 '       g   i     M; iT'       Eg#   \
        P                  ! 4       T,
          pT P                  '       dZ   T P                  P                  f   Q hT P                  P                  P                  T P                  \        Pd                  T4       T P                  '       d   \        P                   ! \"        P$                  4      '       d`   \'        \        \(        P*                  T P,                  T P                  ^ ,          T P                  ^,          R	\        Pd                  TR7       h i ; i5i)
z=Get or create a AsyncConnection. Can raise ConnectionFailure.NzConnection pool was closedru  z?Attempted to check out a connection from closed connection poolT)rr  Fra  rt  )4r  r  r  r%  rb   rc   rd   rs   rp   rq   rv  rS   r.   r  rt   r*   rX  rY  rZ  r,   r+   rx  r   r  r  r  r   get_timeoutget_deadlinewait_queue_timeoutr  ry  r  r  r'   r7  _raise_wait_queue_timeoutr  r  r  r  r  popleft
IndexError	_perishedr8  r1  r   r/   r  rw  r   )	r   rj  rM  r\  deadliner   rP   r;  emitted_events	   &&&      rZ   rd  Pool._get_conn  s     88ryy{"**,,,;;;~~'*??H$$$yy11===		**NNLL"@"L"Lh ''',>,K,KGMM,Z,Z&4DD!__#||A#||A78DD'	 #Q  9999  A%  9 ))+HYY)))~~'$))*F*FFHH>>>>$$%:t$L}}t'9'999A(T^^%55t-dnngFFF }}t'9'99--/223HI(()>4(PMMQM "> @	yyyy##q(#" !y ,  4444,,-Bu,U#zzzT]]T=Q=Q-QAI(T^^-="=t%5d6O6OQX%YYY  $zzzT]]T=Q=Q-Q $ 9 9 @ @ B,0M ::;PQ001FSX0Y+#zz113 54" !^^D111#  2?%)\\'\%BB#'#<#<#<#< MMQ.M 55<<> $=#<#<9 | o -0 999 " G	 ">>>$ !yyy 5  Z & +*+ 5444$ 2
  C#<#<#<#<4#<#<#<#< MMQ.M 55<<> $=#<#<#<#<#<  	oo&<&B&BCCC~~~~"''1,'%%'	 &~~~~~ !=>>+.CC(((9955AAAII..RR&D&O&OQY +++0B0O0OPWP]P]0^0^* 8 H H!%#'<<?#'<<?]<GG#+	 9	s#  8d"V*d"-d" A*d"+)d"Bd"V-d"V35d" V0d" 1d"Ad"Wd"!6W7WW	WA4Wd"W
d"%\ =W6>\ W<\ (W9)!\ 
X\ %Y4"Y7YX	YY+AY	X#\ .Y
/\ ;\ Y*	\ \ #Z 8Y-9Z =\ Y0\ 4Y5\ Y3\  d"-d"0d"3W	9V<:
W	W	
d"Wd"W3	W" 
W3	+W3	-	d"6\ 9\ <X	X
X	X	
\ Y$YYYY
\ Y'	Y
Y'	Y'	!
\ -Z 0\ 3\ 5Z	;Y><
Z	Z		
\ \,Z/-\14[7	%\0[31\7\=\ >
\	\\\ d*"d]d*]-
+d/A_d_d_/_
_/(_/*d;-d)A*d)d>A!dd"c                    V ^8  d   QhRRRR/# )rO   rP   rM   r   r   rX   )rY   s   "rZ   r[   r  2  s     I$ I$/ I$d I$r]   c                
  "   VP                   pVP                  pRVn        RVn         RVn        V P                  P	                  V4       V P
                  P                  pV P                  ;_uu_4       GRj  xL
  V P                  P	                  VP                  4       RRR4      GRj  xL
  V P                  '       d-   Vf   Q hVP                  V P                  VP                  4       V P                  '       d   \        P                   ! \"        P$                  4      '       dZ   \'        \        \(        P*                  V P,                  V P                  ^ ,          V P                  ^,          VP                  R7       V P.                  \0        P2                  ! 4       8w  d   V P5                  4       G Rj  xL
  EMNV P6                  '       d*   VP9                  \:        P<                  4      G Rj  xL
  EMVP6                  '       Ed   V P                  '       d<   Vf   Q hVP?                  V P                  VP                  \:        P@                  4       V P                  '       d   \        P                   ! \"        P$                  4      '       d   \'        \        \(        PB                  V P,                  V P                  ^ ,          V P                  ^,          VP                  \E        \:        P@                  4      \:        P@                  R7       MRpV P                  ;_uu_4       GRj  xL
  V PG                  VPH                  VPJ                  4      '       d   RpMiVPM                  4        VPO                  \Q        V PR                  4      4       V PT                  PW                  V4       V PX                  P[                  4        RRR4      GRj  xL
  V'       d(   VP9                  \:        P\                  4      G Rj  xL
  V P^                  ;_uu_4       GRj  xL
  V'       d   V ;P`                  ^,          un0        M!V'       d   V ;Pb                  ^,          un1        V ;Pd                  ^,          un2        V ;Pf                  ^,          un3        V ;Ph                  ^,          un4        V P^                  P[                  4        RRR4      GRj  xL
  R#  ELp EL>  + GRj  xL 
 '       g   i     ELV; i ELO EL EL EL7  + GRj  xL 
 '       g   i     ELO; i EL( EL LX  + GRj  xL 
 '       g   i     R# ; i5i)zvReturn the connection to the pool, or if it's closed discard it.

:param conn: The connection to check into the pool.
FNrP  re  T)5r   r   r   r  r  rp   rq   r  r  r   rs   publish_connection_checked_inrS   rT   rt   r*   rX  rY  rZ  r,   r+   	CHECKEDINr   r  r  r  r%  rb   r   r/   r  rg  r  rh  r-   r,  r   r   r  r  rW   rg   r  r9  r  r7  r   r  r  r  r  r  r  )r   rP   txncursorrr   r   s   &&    rZ   r   Pool.checkin2  sW    
 oo##"%%d+II..	9999  (()<)<= 9   (((33DLL$''J###(:(G(G(V(V"0::<<?<<?#'77 88ryy{"**,,,{{{oo&<&H&HIII((($00077dgg/E/K/K +++0B0O0OPWP]P]0^0^* 8 D D!%#'<<?#'<<?+/77?@V@\@\]4::	 #
9999 ,,T__dooNN%)
557//T5E5E0FG

--d31188: %9 //*@*F*FGGG>>>>

a
"MMQM1$  A% NN!!# ">>k 999 - J* %999 H!>>>sU  A7U9S):U=&S/#U.S,/U=U)U-BU=T>U"U8T9UU$AU1)UBU6T7U:BTUTU+"UT5U*T8+U.*T=A>T=U"T;#U,U/T		5S86
T		T		
UUUUT2	T!
T2	*T2	,
U8U;U=U	U
U	U		Uc                    V ^8  d   QhRRRR/# )rO   rP   rM   r   rW   rX   )rY   s   "rZ   r[   r  }  s     # #O # #r]   c                R  "   VP                  4       pV P                  P                  eD   W P                  P                  8  d*   VP                  \        P
                  4      G Rj  xL
  R# V P                  pVeM   V^ 8X  g   W#8  d@   VP                  4       '       d*   VP                  \        P                  4      G Rj  xL
  R# V P                  VP                  VP                  4      '       d*   VP                  \        P                  4      G Rj  xL
  R# R#  L L_ L5i)aX  Return True and close the connection if it is "perished".

This side-effecty function checks if this socket has been idle for
for longer than the max idle time, or if the socket has been closed by
some external network error, or if the socket's generation is outdated.

Checking sockets lets us avoid seeing *some*
:class:`~pymongo.errors.AutoReconnect` exceptions on server
hiccups, etc. We only check if the socket was closed by an external
error if it has been > 1 second since the socket was checked into the
pool to keep performance reasonable -
we can't avoid AutoReconnects completely anyway.
NTF)r  rp   r2  r   r/   r4  r  rv  r  r,  r   r   r   )r   rP   r  check_interval_secondss   &&  rZ   r  Pool._perished}  s      !224 II++7!II$C$CC//"8"="=>>>!%!=!=!-"a'+<+U!!oo&<&B&BCCC  $//BB//"8">">??? ? D @sB   A%D''D!(8D'!"D'D#1D'6"D'D%	D'#D'%D'c                    V ^8  d   QhRRRR/# )rO   rj  r  r   r	   rX   )rY   s   "rZ   r[   r    s     %
 %
u %
 %
r]   c                	   V P                   P                  p\        P                  ! 4       V,
          pV P                  '       d2   Vf   Q hVP                  V P                  \        P                  V4       V P                  '       d   \        P                  ! \        P                  4      '       d`   \        \        \        P                   V P"                  V P                  ^ ,          V P                  ^,          R\        P                  VR7       \$        P&                  ! 4       ;'       g    V P                   P(                  pV P                   P*                  '       du   V P,                  V P.                  ,
          V P0                  ,
          p\3        RP5                  V P                   P6                  V P.                  V P0                  VV4      4      h\3        RV P                   P6                   RV 24      h)NzBWait queue timeout elapsed without a connection becoming availableru  zTimeout waiting for connection from the connection pool. maxPoolSize: {}, connections in use by cursors: {}, connections in use by transactions: {}, connections in use by other operations: {}, timeout: {}zMTimed out while checking out a connection from connection pool. maxPoolSize: z, timeout: )rp   rq   rc   rd   rs   rv  rS   r.   TIMEOUTrt   r*   rX  rY  rZ  r,   r+   rx  r   r   r}  r  r   r  r  r  r!   rY   r  )r   rj  rr   r\  r   	other_opss   &&    rZ   r  Pool._raise_wait_queue_timeout  s|   II..	>>#&;;   (((99<DDh ###(:(G(G(V(V"0@@<<?<<?[4<<#	 ##%EE)E)E99"""++dmm;djjHI'7 8>vII++MMJJ8	  $ II334KyJ
 	
r]   c                   V ^8  d   QhRR/# r   rX   )rY   s   "rZ   r[   r    s     & & &r]   c                	j    \         '       d'   V P                   F  pVP                  R 4       K  	  R # R # r   )rs  r  r   )r   rP   s   & rZ   __del__Pool.__del__  s(     8

% # r]   )__pinned_socketsr  r   r  r  r  r  r  rS   r  rs   rt   r|   rV   rg   r  r  r  r  r  r  rp   r  r  r  r  )FN)TNF)NFr   )r  r  r  r  r   r   propertyrb   r  r  r   r%  rm  r,  r<  rJ  r8  
contextlibasynccontextmanagerro  ry  rd  r   r  r  r  r  rX   r]   rZ   rR   rR     s    Tl" . .[Hz=
4&/C,J1Un ##L% $L%\4BI$V#J%
N& &r]   rR   )v
__future__r   r  r  r  rY  r  rD  rF  rg  rc   r_   typingr   r   r   r   r   r	   r
   r   r   bsonr   pymongor   r   #pymongo.asynchronous.client_sessionr   pymongo.asynchronous.helpersr   pymongo.asynchronous.networkr   pymongo.commonr   r   r   r   r   pymongo.errorsr   r   r   r   r   r   r   r   r    r!   r"   pymongo.hellor#   r$   pymongo.helpers_sharedr%   r&   pymongo.lockr'   r(   r)   pymongo.loggerr*   r+   r,   r-   pymongo.monitoringr.   r/   pymongo.network_layerr0   r1   r2   pymongo.pool_optionsr3   pymongo.pool_sharedr4   r5   r6   r7   pymongo.read_preferencesr8   pymongo.server_apir9   pymongo.server_typer:   pymongo.socket_checkerr;   r<   bson.objectidr=   pymongo.asynchronous.authr>   r?   !pymongo.asynchronous.mongo_clientr@   rA   pymongo.compression_supportrB   rC   rD   pymongo.messagerE   rF   pymongo.read_concernrG   rH   pymongo.typingsrI   rJ   pymongo.write_concernrK   rs  rM   r  r  r  rR   rX   r]   rZ   <module>r     s   #     	  
 
  
 
 
 ' ) O 7 0     - O 
  a ` ,  4 . + 0!&6F\ 
 10462 Z
 Z
z| + +> T& T&r]   