+
    8i                       ^ 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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)H*t*H+t+H,t, ^ RI-H.t.H/t/ ^ R	I0H1t1H2t2 ^ R
I3H4t4H5t5H6t6 ^ RI7H8t8H9t9H:t:H;t; ^ RI<H=t=H>t> ^ RI?H@t@HAtAHBtB ^ RICHDtD ^ RIEHFtFHGtGHHtHHItI ^ RIJHKtK ^ RILHMtM ^ RINHOtO ^ RIPHQtQ ^ RIRHStS ^ RITHUtU ^ RIVHWtW ]'       dM   ^ RIHXtX ^ RIYHZtZ ^ RI[H\t\H]t]H^t^ ^ RI_H`t`Hata ^ RIbHctc ^ RIJHdtd ^ RIeHftf ^ RIRHgtg ^ RIhHitiHjtj ^ R IkHltlHmtm ^ R!InHoto R"tp ! R# R$4      tq ! R% R&]*4      tr ! R' R(4      ts ! R) R*4      tt ! R+ R,4      tuR# )-    )annotationsN)	TYPE_CHECKINGAny	GeneratorMappingMutableMappingNoReturnOptionalSequenceUnion)DEFAULT_CODEC_OPTIONS)_csothelpers_shared)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)
_cond_wait_create_condition_create_lock)_CONNECTION_LOGGER_ConnectionStatusMessage
_debug_log _verbose_connection_error_reason)ConnectionCheckOutFailedReasonConnectionClosedReason)NetworkingInterfacereceive_messagesendall)PoolOptions)	SSLErrors_CancellationContext_configured_socket_interface_raise_connection_failure)ReadPreference)_add_to_command)SERVER_TYPE)SocketChecker)_validate_session_write_concern)_handle_reauth)command)CodecOptions)ObjectId)SnappyContextZlibContextZstdContext)_OpMsg_OpReply)ReadConcern)_ServerMode)_AuthContext)ClientSession)MongoClient_MongoClientErrorHandler)_Address_CollationIn)WriteConcernTc                     ] 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
Connectiona  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
/# )   connr-   poolPooladdressztuple[str, int]idintis_sdambool )formats   "V/var/www/html/photoedit/myenv/lib/python3.14/site-packages/pymongo/synchronous/pool.py__annotate__Connection.__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_contextr8   socket_checkeroidc_token_gen_idnegotiated_mechsauth_ctxgenpool_genget_overall
generationreadyr2   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__Connection.__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Connection.set_conn_timeout   s/    '''#		%%g.r]   c               $    V ^8  d   QhRRRRRR/# )rO   clientzMongoClient[Any]cmdz"Optional[MutableMapping[str, Any]]r   r   rX   )rY   s   "rZ   r[   r\      s$      &-O	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Connection.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Connection.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Connection.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       R # V P                  \        P                  4       R # N)ra   checkin
close_connr,   STALE)r   rQ   s   & rZ   unpinConnection.unpin   s/    }}LLOO2889r]   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Connection.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     ' ', 'r]   c                	&    V P                  R R 4      # r   )_hellor   s   &rZ   helloConnection.hello   s    {{4&&r]   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                		   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      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# )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.synchronousr   rE   from_credentialsrS   speculate_commandrc   rd   r;   r   r    rg   rh   ri   rj   rk   logical_session_timeout_minutesis_readablerl   rm   server_typer7   	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   Connection._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()0((99%NH+3+E+E+G(+75M12HNN$Ell7CylY#~~/%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r]   c                   V ^8  d   QhRR/# r   rX   )rY   s   "rZ   r[   r\   O  s      ^ r]   c                	    V P                  R 4      pVP                  V n        VP                  4       pV^ ,          p\        P                  ! W0P
                  4       V# r   )r.   r   unpack_responser   _check_command_responserh   )r   replyunpacked_docsresponse_docs   &   rZ   _next_replyConnection._next_replyO  sR    $$T*!..--/$Q'..|=R=RSr]   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_preferencerD   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[ClientSession]r   Optional[MongoClient[Any]]retryable_writer   user_fieldszOptional[Mapping[str, Any]]r   r   r   rX   )rY   s   "rZ   r[   r\   X  s     W2 W2W2 'W2 %	W2
 7W2 W2 >W2 ,W2 .W2 $(W2 *W2 )W2 +W2 W2 W2  1!W2" #W2$ 
%W2r]   c                   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      #   \&        \(        3 d    h \*         d   pT P-                  T4        Rp?R# Rp?ii ; 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 ClientSession instance.
:param client: optional MongoClient 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_sessionr9   
isinstancer   dictacknowledgedr   add_server_api	_apply_tosend_cluster_timerr   rW   ro   _raise_if_not_writabler;   rn   rS   ri   rw   r   r   BaseExceptionr4   )r   r  r  r  r  r  r  r  r  r  r  r  r   r"  r   r#  r   rr   r'  errors   &&&&&&&&&&&&&&&&&   rZ   r;   Connection.commandW  sk   R 	f.1'I $..:D%)C)C)CyGX$%Z[[D!d_Ktf5&4DNN$	mNNM4N4N0NO''7	2 ""*C# $ 8 8..-' /+- 0 !/2 	 	2**511	2s   >AE 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!     2 2E 2 2 2r]   c                   V P                   e.   W P                   8  d   \        RW P                   3,          4      h \        V P                  P                  V4       R#   \
         d   pT P                  T4        Rp?R# Rp?ii ; 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   r/   rP   r   r0  r4   )r   r4  r6  r1  s   &&& rZ   send_messageConnection.send_message  sy    
 )l=O=O.O"?BNPbPbAcd 
	2DII&&0 	2**511	2s    A 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     	2 	2- 	2<S 	2r]   c                     \        WV P                  4      #   \         d   pT P                  T4        Rp?R# Rp?ii ; i)zjReceive a raw BSON message or raise ConnectionFailure.

If any exception is raised, the socket is closed.
N)r.   rj   r0  r4   )r   r;  r1  s   && rZ   r.   Connection.receive_message  s;    
	2"4T5J5JKK 	2**511	2s    ?:?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   r/  !Connection._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   msgr5  r6  rU   r   r   rX   )rY   s   "rZ   r[   r\     s!     	- 	-u 	-C 	-D 	-r]   c                J    V P                  R4       V P                  W4       R# )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)r/  r8  )r   rB  r6  s   &&&rZ   unack_writeConnection.unack_write  s      	##D)#,r]   c               (    V ^8  d   QhRRRRRRRR/# )	rO   r;  rU   rB  r5  r  r  r   r   rX   )rY   s   "rZ   r[   r\     s,      $):Y	r]   c                    V P                  V^ 4       V P                  V4      pVP                  V4      p\        P                  ! WPP
                  4       V# )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.
)r8  r.   command_responser   r  rh   )r   r;  rB  r  r  results   &&&&  rZ   write_commandConnection.write_command  sO     	#q!$$Z0''6 	..v7L7LMr]   c                    V ^8  d   QhRRRR/# )rO   reauthenticaterW   r   r   rX   )rY   s   "rZ   r[   r\     s        4  D  r]   c           
     "   V'       d!   V P                   '       d   RV n        RV n        V P                  '       EgT   V P                  P                  pV'       d   ^ RIHp VP                  W VR7       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# )zXAuthenticate to the server if needed.

Can raise ConnectionFailure or OperationFailure.
NFr   )rM  Tr4  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   rM  r  r   durations   &&   rZ   rU  Connection.authenticate  s    ''' $DJzzzII**E4!!%n!MDJ~~'$*<*<<H$$$~~11177dggxX''',>,K,KGMM,Z,Z&4??!__#||A#||A'+ww' -[' r]   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)     	d 	d0	d;R	d		d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.
z9Can only use session with the MongoClient that started itN)_clientr   )r   r   r  s   &&&rZ   r(  Connection.validate_session  s)     f,&'bcc - r]   c                    V ^8  d   QhRRRR/# )rO   reasonzOptional[str]r   r   rX   )rY   s   "rZ   r[   r\     s       4 r]   c                P   V P                   '       d   R# V P                  4        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# )z$Close this connection with a reason.Nr4  rP  rQ  rR  rS  rb  r1  )rb   _close_connrs   rr   publish_connection_closedrS   rT   rt   r'   rW  rX  rY  r)   r(   CONN_CLOSEDr   r*   )r   rb  s   &&rZ   r   Connection.close_conn  s    ;;;$$$~~11188twwPVW''',>,K,KGMM,Z,Z&4@@!__#||A#||A'+ww;FC 	 -['	 r]   c                   V ^8  d   QhRR/# r   rX   )rY   s   "rZ   r[   r\   4  s      T r]   c                    V P                   '       d   R# RV n         V P                  P                  4         V P                  P	                  4        R#   \
         d     R# i ; i)zClose this connection.NT)rb   r   cancelrP   close	Exceptionr   s   &rZ   re  Connection._close_conn4  sL    ;;;""$	IIOO 		s   A A"!A"c                   V ^8  d   QhRR/# rO   r   rW   rX   )rY   s   "rZ   r[   r\   A  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Connection.conn_closedA  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\   H  s2     8 8)8 )8 +	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.  Connection.send_cluster_timeH  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\   R  s     ; ;&> ;4 ;r]   c                    V P                   P                  '       d"   \        WP                   P                  4       R# R# )zAdd server_api parameters.N)rp   r   r6   )r   r;   s   &&rZ   r,  Connection.add_server_apiR  s)    99GYY%9%9:  r]   c                   V ^8  d   QhRR/# r   rX   )rY   s   "rZ   r[   r\   W  s     2 2$ 2r]   c                	:    \         P                  ! 4       V n        R # r   rc   rd   re   r   s   &rZ   update_last_checkin_time#Connection.update_last_checkin_timeW  s    !%!1r]   c                    V ^8  d   QhRRRR/# )rO   rg   rW   r   r   rX   )rY   s   "rZ   r[   r\   Z  s     ' 'd 't 'r]   c                	    Wn         R # r   )rg   )r   rg   s   &&rZ   update_is_writableConnection.update_is_writableZ  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Connection.idle_time_seconds]  s    ~~$"8"888r]   c                    V ^8  d   QhRRRR/# )rO   r1  r0  r   r	   rX   )rY   s   "rZ   r[   r\   a  s      }  r]   c                	   V P                   '       d   R pM\        P                  pV P                  V4       \	        V\
        \        .\        O54      '       d/   \        V P                  4      p\        V P                  WR7       R # h )Nr   )r   r,   ERRORr   r)  IOErrorOSErrorr1   r"   rp   r4   rS   )r   r1  rb  detailss   &&  rZ   r4   $Connection._raise_connection_failurea  s_      :::F+11Fegw;;<<*4995G%dllESr]   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__Connection.__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__Connection.__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__Connection.__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Connection({}){} at {}z CLOSED )rY   reprrP   rb   rT   r   s   &rZ   __repr__Connection.__repr__  s>    '..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:   r5   PRIMARYr   r;   r8  r.   r/  rD  rJ  rU  r(  r   re  ru  r.  r,  r  r  r  r4   r  r  r  r  __static_attributes__rX   r]   rZ   rM   rM   s   s    9"v/>&#:@'Tl 
 (6'='=9N@D.204*/,0+/-1 %#37 %#W2 W2r2"	2d	-$ D	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   optionsr0   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 Connection
Ninfr4  rP  rQ  rR  )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'   rW  rX  rY  r)   r(   POOL_CREATEDoperation_count_Pool__pinned_socketsncursorsntxns)r   rS   r  rV   r  s   &&&&&rZ   r   Pool.__init__  sn       "))DJ"DJ ()$ 5@4E4E4G
:=% N	$5dii$@!"#+/
 #$99;	  < <		**$6< <		**;; 	
 (,||#3 
 +4995!YY44!!!!&uD %6dii$@!#yy77#   99--999II&&;;dii;; ###(:(G(G(V(V"0==   <<?	
  <<? ))// %& 25
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        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       R #   + '       g   i     R # ; i)Nr4  rP  rQ  rR  )r  r  r  r  rs   rp   rq   publish_pool_readyrS   rt   r'   rW  rX  rY  r)   r(   
POOL_READYr   r   s   &rZ   r   
Pool.ready  s    YYYzzY__,&__
(((9955AAAII..AA$,,O+++0B0O0OPWP]P]0^0^* 8 C C!%#'<<?#'<<? YYYs    AD9AD97)D9!AD99E
	c                   V ^8  d   QhRR/# rp  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   rl  rW   pauser   r  interrupt_connectionsr   r   rX   )rY   s   "rZ   r[   r  %  sJ     [B [B[B [B '	[B
  $[B 
[Br]   c           	     		   V P                   pV P                  ;_uu_ 4        V P                  '       d    R R R 4       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       V P                  P2                  pV'       Ed;   \4        '       gD   \6        P8                  ! X U
u. uF!  qP;                  \<        P>                  4      NK#  	  up
RR/  M(X F"  p
V
P;                  \<        P>                  4       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        '       gE   \6        P8                  ! X U
u. uF!  qP;                  \<        PZ                  4      NK#  	  up
RR/  R # X F"  p
V
P;                  \<        PZ                  4       K$  	  R #   + '       g   i     EL; iu up
i u up
i )Nreturn_exceptionsTr  )r   r  )r4  rP  rQ  rR  	serviceId).r  r  rb   rp   r  r   r  r  r|   r  r  r  r  r  r  r  r  r  r   appendr  r  
notify_allr  rk  rq   rr  asynciogatherr   r,   POOL_CLOSEDrs   publish_pool_closedrS   rt   r'   rW  rX  rY  r)   r(   r   publish_pool_clearedPOOL_CLEAREDr   )r   rl  r  r   r  	old_statenewpidsocketsdiscardkeeprP   contextrr   s   &&&&&        rZ   _resetPool._reset%  sy    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V]^V]doo&<&H&HIV]^&*
 $DOO$:$F$FG $$$$ ,,,--dll;''',>,K,KGMM,Z,Z&4@@!__#||A#||A -[' I,,,((($00022#-.C 3 
 +++0B0O0OPWP]P]0^0^* 8 E E!%#'<<?#'<<?", 8PWXPWoo&<&B&BCPWX&*
 $DOO$:$@$@A $e ^^R _J Ys<   SSS#S?D"S"AS3#S'S-'S S	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 = =r]   c                    Wn         V P                  ;_uu_ 4        V P                   F  pVP                  V P                   4       K   	  RRR4       R#   + '       g   i     R# ; 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  sA     'YYY::**4+;+;< & YYYs   /AA%	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)     e e,eLPe	er]   c                	,    V P                  R WR7       R# )F)rl  r   r  Nr  )r   r   r  s   &&&rZ   reset
Pool.reset  s     	%Jdr]   c                   V ^8  d   QhRR/# r   rX   )rY   s   "rZ   r[   r    s     . .T .r]   c                	,    V P                  R R R7       R# )F)rl  r  Nr  r   s   &rZ   reset_without_pausePool.reset_without_pause  s    %u-r]   c                   V ^8  d   QhRR/# r   rX   )rY   s   "rZ   r[   r    s        t  r]   c                	*    V P                  R R7       R# )T)rl  Nr  r   s   &rZ   rl  
Pool.close  s    $r]   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, C, C,r]   c           	        V P                   ;_uu_ 4        V P                  \        P                  8w  d    RRR4       R#  RRR4       V P                  P
                  Ee   . pV P                   ;_uu_ 4        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       \        '       gD   \        P                  ! V Uu. uF!  q3P                  \        P                  4      NK#  	  upRR/  M(V F"  pVP                  \        P                  4       K$  	   V P                   ;_uu_ 4        \#        V P                  4      V P$                  ,           V P                  P&                  8  d    RRR4       R# V P(                  V P                  P&                  8  d    RRR4       R# V ;P(                  ^,          un        RRR4       Rp V P*                  ;_uu_ 4        V P,                  V P.                  8  d    RRR4       V'       dQ   V P*                  ;_uu_ 4        V ;P,                  ^,          un        V P*                  P1                  4        RRR4       V P                   ;_uu_ 4        V ;P(                  ^,          un        V P                   P1                  4        RRR4       R# V ;P,                  ^,          un        RpRRR4       V P3                  4       pRpV P                   ;_uu_ 4        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       V'       d   VP                  \        P@                  4        V'       dQ   V P*                  ;_uu_ 4        V ;P,                  ^,          un        V P*                  P1                  4        RRR4       V P                   ;_uu_ 4        V ;P(                  ^,          un        V P                   P1                  4        RRR4       R#  V'       dQ   V P*                  ;_uu_ 4        V ;P,                  ^,          un        V P*                  P1                  4        RRR4       V P                   ;_uu_ 4        V ;P(                  ^,          un        V P                   P1                  4        RRR4       EK    + '       g   i     EL; i  + '       g   i     ELl; iu upi   + '       g   i     EL]; i  + '       g   i     EL; i  + '       g   i     R# ; i  + '       g   i     EL; i  + '       g   i     EL; i  + '       g   i     EL; i  + '       g   i     R# ; i  + '       g   i     EL; i  + '       g   i     EK  ; i  T'       de   T P*                  ;_uu_ 4        T ;P,                  ^,          un        T P*                  P1                  4        RRR4       M  + '       g   i     M; iT P                   ;_uu_ 4        T ;P(                  ^,          un        T P                   P1                  4        RRR4       i   + '       g   i     i ; i; 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  poprr  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  sc    YYYzzY__, Y,  99**6KJJJ

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

--d3,,44T5H5HI  OO$:$@$@A222*1188: 3 ^^^MMQ&MNN))+ $^  222*1188: 3 ^^^MMQ&MNN))+ $^u YY  \  @ 322 $^^7 /.. YY 322 $^^	 322 $^^ 222*1188: 3222 ^^^MMQ&MNN))+ $^^^s
  !T?8UA%U'U'AU,&U,?U,#X! 7V(X! 84V 4VV(!.X! )V<9A V<9X! 	X! 4W4W$04W8 4X?U	U$	,U=	 V	V%	(V9	3	X! <W		X! W!	$W5	8X		X	![2>4Y;	2	[2;Z[2"4[		[2[/*[2c                    V ^8  d   QhRRRR/# )rO   r1  r0  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   r1   socketgaierrorsslSSLEOFErrorSSLZeroReturnError_add_error_label)r   r1  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A UZ Ur]   c                J
   V P                   ;_uu_ 4        V P                  pV ;P                  ^,          un        \        4       pV P                  P	                  V4       RRR4       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      p\E        YPT P                  XT PF                  4      pT P                   ;_uu_ 4        T P                  P	                  TPH                  4       T P                  P+                  X4       RRR4       XPJ                  '       d   TPH                  PM                  4        Rp	 T PF                  '       g$   TPO                  4        Rp	TPP                  T n(        T'       d   TPS                  TRR7       TPU                  4        T'       d0   TPX                  PZ                  P]                  TP^                  4       T#   + '       g   i     ELN; i  \(         Ed   pT P                   ;_uu_ 4        T P                  P+                  X4       RRR4       M  + '       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  + '       g   i     EL; i  \(         d   p
T P                   ;_uu_ 4        T P                  P+                  TPH                  4       RRR4       M  + '       g   i     M; iT	'       g   T P7                  T
4       TPW                  \.        P0                  4       h Rp
?
ii ; i)zConnect to Mongo and return a new Connection.

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r4  rP  rQ  rR  rS  rd  r  FT)completed_handshake)0r  r  r2   r  addrp   rq   rs   publish_connection_createdrS   rt   r'   rW  rX  rY  r)   r(   CONN_CREATEDr   r3   r0  r  rf  r,   r  rg  r*   rH  r)  r  r  r1   r"   r4   rM   rV   r   	cancelledrk  r   rg   contribute_socketrU  r   r   	_topologyreceive_cluster_timer   )r   rK  conn_idtmp_contextrr   networking_interfacer1  r  rP   completed_helloes   &&         rZ   r6  Pool.connect  s    YYY--G##q(#.0K  $$[1  II..	   (((00wG###(:(G(G(V(V"0==<<?<<?#*	#?dii#X 6 .dllGT\\ZYYY  $$T%8%89  ((5     &&(	<<<

"&#'#3#3 ))$E)J NN$$99$:L:LM[ YY0  	$$,,[9 $$$ ,,,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 YY   	$$,,T-@-@A "--a0OO2889	s   AJ%> J9 AQ/R *R 	#R %J6	9Q,Q'K>5	Q'>L	Q'#AQ'&)Q'CQ''Q,/R 	T"T"&S	TS!T,1TT"c                    V ^8  d   QhRRRR/# )rO   rK  rL  r   zGenerator[Connection, None]rX   )rY   s   "rZ   r[   r  E  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      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        V P*                  P-                  VP.                  4       RRR4       Vx  TP2                  '       dT   T P(                  ;_uu_ 4        T P@                  P-                  T4       T ;PB                  ^,          un!        RRR4       R# TP4                  '       dT   T P(                  ;_uu_ 4        T P@                  P-                  T4       T ;PD                  ^,          un"        RRR4       R# TP<                  '       d   T P?                  T4       R# R#   + '       g   i     EL; i  \0         d    TP2                  ;'       g    TP4                  pT'       d*   \6        P8                  ! 4       w  rxp	TP;                  Yx4       T'       g$   TP<                  '       d   T P?                  T4       h i ; i  + '       g   i     R# ; i  + '       g   i     R# ; i5i)a  Get a connection from the pool. Use with a "with" statement.

Returns a :class:`Connection` 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  rK  rO  )#rp   rq   rc   rd   rs   $publish_connection_check_out_startedrS   rt   r'   rW  rX  rY  r)   r(   CHECKOUT_STARTEDr   	_get_connpublish_connection_checked_outrT   CHECKOUT_SUCCEEDEDr  r  rP  r   r0  r   r   sysexc_infohandler   r   r  r  r  )
r   rK  rr   checkout_started_timerP   r[  pinnedexc_typeexc_val_s
   &&        rZ   checkoutPool.checkoutD  s    & II..	 $ 0   (((::4<<H###(:(G(G(V(V"0AA<<?<<? ~~3~E>>#&;;   (((44T\\477HU###(:(G(G(V(V"0CC<<?<<?#'77#	$$(()<)<= J  ???%%))$/

a
  %%))$/"  [[[LL 5   	
 __::(:(:F (+||~$1x1dkkkT"	  s   A0O.3)O.CO.*)O.AO./L: &L&)L: 5O.O.5OO.,O. 5O5O.O.&L7	1	L: :OO-0OO0OO.O		O.O+	%	O.c               $    V ^8  d   QhRRRRRR/# )rO   rh  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r4  rP  rQ  rR  rb  r1  rT  zconnection pool pausedr  )r  r  r  rc   rd   rs   rp   rq   #publish_connection_check_out_failedrS   r+   
CONN_ERRORrt   r'   rW  rX  rY  r)   r(   CHECKOUT_FAILEDr   r"   r4   r   )r   rh  rp  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   rh  r  rK  rL  r   rM   rX   )rY   s   "rZ   r[   r    s)      %*5W	r]   c                    V P                   \        P                  ! 4       8w  d   V P                  4        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        V ;P2                  ^,          un        RRR4       \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        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      '       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       RpRpRp V P0                  ;_uu_ 4        V ;PJ                  ^,          un%        RpRRR4       VEf   V PL                  ;_uu_ 4        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[   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       V'       d    V PY                  V4      '       d   RpEKR  EKU   V P[                  VR7      pV PL                  ;_uu_ 4        V ;PP                  ^,          un(        V PL                  PG                  4        RRR4       EK   RTn3        T#   + '       g   i     EL; i  + '       g   i     EL); i  + '       g   i     EL; i  \V         d    T ;PP                  ^,          un(         ELi ; i  + '       g   i     EL; i  + '       g   i     EKR  ; i  T PL                  ;_uu_ 4        T ;PP                  ^,          un(        T PL                  PG                  4        RRR4       i   + '       g   i     i ; i; i  \\         Ed    T'       d    TP_                  \`        Pb                  4       T P<                  ;_uu_ 4        T ;P@                  ^,          un         T'       d   T ;PJ                  ^,          un%        T P<                  PG                  4        RRR4       M  + '       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)
z8Get or create a Connection. Can raise ConnectionFailure.NzConnection pool was closedrs  z?Attempted to check out a connection from closed connection poolT)rp  Fr_  rr  )4r  r  r  r#  rb   rc   rd   rs   rp   rq   rt  rS   r+   r  rt   r'   rW  rX  rY  r)   r(   rv  r   r  r  r  r   get_timeoutget_deadlinewait_queue_timeoutr  rw  r  r  r$   r5  _raise_wait_queue_timeoutr  r  r  r  r  popleft
IndexError	_perishedr6  r0  r   r,   r  ru  r   )	r   rh  rK  r[  deadliner   rP   r9  emitted_events	   &&&      rZ   rb  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  YYY  A%   ))+HYY)))~~'$))*F*FFHH^^^$$%:t$L}}t'9'999A(T^^%55t!$..':: }}t'9'99--/223HI(()>4(PMMQM  @	##q(#"  , ...,,-Bu,U#zzzT]]T=Q=Q-QAI(T^^-="=t)$*C*CWMM  $zzzT]]T=Q=Q-Q $ 9 9 @ @ B,0M ::;PQ001FSX0Y+#zz113 /" ~~d++#  ,?#||G|<!666 MMQ.M 55<<> 769 |  YY ^^$ * & +*+ /..2 766T666 MMQ.M 55<<> 7666  	 6 < <="''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  	T0?6U6B.U3X( U#!X( %V*"VAVAV7U,X( !X( 8X( W  X( '4V+X( 0U	U	U)	#	X( ,$VVVVV(	"	X( +V=	6
X(  X%4X			X%X"X%%X( (`<3`/A[	`[`)-`A*`)`,A!`c                    V ^8  d   QhRRRR/# )rO   rP   rM   r   r   rX   )rY   s   "rZ   r[   r  .  s     I$ I$J I$4 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        V P                  P	                  VP                  4       RRR4       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        EM.V P6                  '       d"   VP9                  \:        P<                  4       EMV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        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       V'       d    VP9                  \:        P\                  4       V P^                  ;_uu_ 4        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       R#   + '       g   i     EL; i  + '       g   i     EL; i  + '       g   i     R# ; i)zvReturn the connection to the pool, or if it's closed discard it.

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

--d31188:  OO$:$@$@A^^^

a
"MMQM1$  A% NN!!# ^k YYN YY ^^s,   3&RBR3,*SA>SR0	3S	S	c                    V ^8  d   QhRRRR/# )rO   rP   rM   r   rW   rX   )rY   s   "rZ   r[   r  y  s     # #j #T #r]   c                   VP                  4       pV P                  P                  e<   W P                  P                  8  d"   VP                  \        P
                  4       R# V P                  pVeE   V^ 8X  g   W#8  d8   VP                  4       '       d"   VP                  \        P                  4       R# V P                  VP                  VP                  4      '       d"   VP                  \        P                  4       R# R# )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.
TF)r  rp   r0  r   r,   r2  r  ru  r  r*  r   r   r   )r   rP   r  check_interval_secondss   &&  rZ   r  Pool._perishedy  s     !224 II++7!II$C$CCOO2778!%!=!=!-"a'+<+U!! 6 < <=  $//BBOO2889r]   c                    V ^8  d   QhRRRR/# )rO   rh  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 availablers  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   rt  rS   r+   TIMEOUTrt   r'   rW  rX  rY  r)   r(   rv  r   r   r{  r}  r   r  r  r  r   rY   r  )r   rh  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   )rr  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#  rl  r*  r:  rH  r6  
contextlibcontextmanagerrm  rw  rb  r   r  r~  r  r  rX   r]   rZ   rR   rR     s    Tl" . .[Bz=e
. /C,J1Un L L\4BI$V#J%
N& &r]   rR   )v
__future__r   r
  r  r  rX  r  rB  rD  re  rc   r_   typingr   r   r   r   r   r	   r
   r   r   bsonr   pymongor   r   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_layerr-   r.   r/   pymongo.pool_optionsr0   pymongo.pool_sharedr1   r2   r3   r4   pymongo.read_preferencesr5   pymongo.server_apir6   pymongo.server_typer7   pymongo.socket_checkerr8   "pymongo.synchronous.client_sessionr9   pymongo.synchronous.helpersr:   pymongo.synchronous.networkr;   r<   bson.objectidr=   pymongo.compression_supportr>   r?   r@   pymongo.messagerA   rB   pymongo.read_concernrC   rD   pymongo.synchronous.authrE   rF    pymongo.synchronous.mongo_clientrG   rH   pymongo.typingsrI   rJ   pymongo.write_concernrK   rr  rM   r  r  r  rR   rX   r]   rZ   <module>r     s   #     	  
 
  
 
 
 ' )     - O 
  P O ,  4 . + 0 N 6 /!& 
 1045@V62 X
 X
v| + +> R& R&r]   