+
    8iɲ                    J   R t ^ 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Ht ^ RIHtHtHtHtHtHt ^ RI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# ^ RI$H%t% ^ RI&H't'H(t(H)t) ^ R	I*H+t+H,t,H-t-H.t.H/t/ ^ R
I0H1t1 ^ RI2H3t3 ^ RI4H5t5H6t6H7t7H8t8H9t9 ^ RI:H;t;H<t< ^ RI=H>t>H?t? ^ RI@HAtA ^ RIBHCtC ^ RIDHEtEHFtFHGtGHHtHHItI ]'       d   ^ RIJHKtK ^ RILHMtM ^ RINHOtOHPtP RtQ]R! ]! ]S4      P                  4      tUR R ltV ! R R4      tW ! R R4      tXR R ltYR R ltZR# ) z<Internal class to monitor a topology of one or more servers.)annotationsN)Path)TYPE_CHECKINGAnyCallableMappingOptionalcast)_csotcommonhelpers_sharedperiodic_executor)	ConnectionFailureInvalidOperationNetworkTimeoutNotPrimaryErrorOperationFailurePyMongoErrorServerSelectionTimeoutErrorWaitQueueTimeoutError
WriteError)Hello)
_cond_wait_create_condition_create_lock)_SDAM_LOGGER_SERVER_SELECTION_LOGGER
_debug_log_SDAMStatusMessage_ServerSelectionStatusMessage)PoolOptions)ServerDescription)	Selectionany_server_selectorarbiter_server_selectorsecondary_server_selectorwritable_server_selector)_ServerSession_ServerSessionPool)MonitorBase
SrvMonitor)Pool)Server)SRV_POLLING_TOPOLOGIESTOPOLOGY_TYPETopologyDescription)_updated_topology_description_srv_pollingupdated_topology_description)ObjectId)TopologySettings)ClusterTime_AddressTc                    V ^8  d   QhRRRR/# )   	queue_refz"weakref.ReferenceType[queue.Queue]returnbool )formats   "Z/var/www/html/photoedit/myenv/lib/python3.14/site-packages/pymongo/synchronous/topology.py__annotate__r>   W   s      $F 4     c                    V ! 4       pV'       g   R #   VP                  4       pVw  r4V! V!   K    \        P                   d     R# i ; i)FT)
get_nowaitqueueEmpty)r8   qeventfnargss   &    r=   process_events_queuerH   W   sO    A
	LLNE HBI	 {{ 	
 	s   0 A	A	c                  T   ] tR t^htRtR R ltR R ltR R ltR\R	 R
 lltR]R R llt	R\R R llt
R\R R lltR^R R lltR_R R l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" 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R/ R0 ltR1 R2 ltR3 R4 lt]R5 R6 l4       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%RC RD lt&RE RF lt'RG RH lt(RI RJ lt)RK RL lt*RM RN lt+RO RP lt,RQ RR lt-RS RT lt.RU RV lt/RW RX lt0RY RZ lt1R[t2R# )aTopologyz*Monitor a topology of one or more servers.c                   V ^8  d   QhRR/# )r7   topology_settingsr3   r;   )r<   s   "r=   r>   Topology.__annotate__k   s     m4 m4*: m4r?   c           	     	  a VP                   V n         VP                  P                  V n        V P                  R J;'       d    V P                  P                  V n        V P                  R J;'       d    V P                  P                  V n        R V n        R V n	        V P
                  '       g   V P                  '       d   \        P                  ! ^dR7      V n        \        P                  ! \        P                  4      '       d+   \!        \        \"        P$                  V P                   R7       V P                  '       d]   V P                  f   Q hV P                  f   Q hV P                  P'                  V P                  P(                  V P                   334       Wn        \-        VP/                  4       VP1                  4       VP2                  R R V4      pW n        \-        \6        P8                  / R R R V P*                  4      pV P                  '       dh   V P                  f   Q hV P                  f   Q hV P                  P'                  V P                  P:                  W0P4                  V P                   334       \        P                  ! \        P                  4      '       dI   \!        \        \"        P<                  V P                   \?        V4      \?        V P4                  4      R7       VP@                   F  pV P
                  '       d]   V P                  f   Q hV P                  f   Q hV P                  P'                  V P                  PB                  W@P                   334       \        P                  ! \        P                  4      '       g   K  \!        \        \"        PD                  V P                   V^ ,          V^,          R7       K  	  \G        VPI                  4       4      V n%        RV n&        RV n'        \Q        4       V n)        \U        V PR                  \V        '       d   V P*                  PX                  MR 4      V n-        / V n.        R V n/        R V n0        \c        4       V n2        V P
                  '       g   V P                  '       d   V P                  f   Q hR V3R llp\f        Ph                  ! \j        Pl                  \j        Pn                  VRR	7      p\p        Pr                  ! V P                  VPt                  4      oW`n	        VPw                  4        R V n<        V P*                  Pz                  e7   V P*                  P|                  '       g   \        W P*                  4      V n<        . V n@        R # )
N)maxsizemessage
topologyIdrQ   rR   previousDescriptionnewDescription)rQ   rR   
serverHost
serverPortFc                   V ^8  d   QhRR/# )r7   r9   r:   r;   )r<   s   "r=   r>   'Topology.__init__.<locals>.__annotate__   s     2 2D 2r?   c                    < \        S 4      # N)rH   )weaks   r=   target!Topology.__init__.<locals>.target   s    +D11r?   pymongo_events_thread)intervalmin_intervalr]   name)A_topology_id_pool_options_event_listeners
_listenersenabled_for_server_publish_serverenabled_for_topology_publish_tp_events_Topology__events_executorrB   Queuer   isEnabledForloggingDEBUGr   r   START_TOPOLOGYputpublish_topology_opened	_settingsr/   get_topology_typeget_server_descriptionsreplica_set_name_descriptionr.   Unknown$publish_topology_description_changedTOPOLOGY_CHANGEreprseedspublish_server_openedSTART_SERVERlistserver_descriptions_seed_addresses_opened_closedr   _lockr   _IS_SYNCcondition_class
_condition_servers_pid_max_cluster_timer(   _session_poolr   PeriodicExecutorr   EVENTS_QUEUE_FREQUENCYMIN_HEARTBEAT_INTERVALweakrefrefcloseopen_srv_monitorfqdnload_balancedr*   _monitor_tasks)selfrL   topology_description
initial_tdseedr]   executorr\   s   &&     @r=   __init__Topology.__init__k   s%   -::+99JJ#d:aat?a?a??$6__4??;_;_ 15&*4#3#3#3 ;;s3DL$$W]]33*99,, <<+++??...LLdooEEHYHYG[\]*2//1557.. 
 1(!!2tT4

 <<+++??...LLOOHH!2!2D4E4EF $$W]]33*::,,$($4#D$5$56 &++D###||///222  $//"G"G$PaPaIb!cd((77 .;;#00#Aw#Aw ,  $$8$L$L$NO!^
+JJ((66
 13#'	8</14#3#3#3<<+++2 2 )9966#::,	H ;;t||X^^<D%-"MMO >>*4>>3O3O3O *4 @D 24r?   c                   V ^8  d   QhRR/# r7   r9   Noner;   )r<   s   "r=   r>   rM      s     %" %"d %"r?   c                ~   \         P                  ! 4       pV P                  f   Wn        MWP                  8w  d   Wn        \        P                  R,          R8  d   R\
        3/pMR^/p\        P                  ! R/ VB  V P                  ;_uu_ 4        V P                  P                  4        F  pVP                  4        K  	  V P                  P                  4        RRR4       V P                  ;_uu_ 4        V P                  4        RRR4       R#   + '       g   i     L?; i  + '       g   i     R# ; i)a{  Start monitoring, or restart after a fork.

No effect if called multiple times.

.. warning:: Topology is shared among multiple threads and is protected
  by mutual exclusion. Using Topology from a process other than the one
  that initialized it will emit a warning and may result in deadlock. To
  prevent this from happening, MongoClient must be created after any
  forking.

N:Nr7   Nskip_file_prefixes
stacklevel)      )zMongoClient opened before fork. May not be entirely fork-safe, proceed with caution. See PyMongo's documentation for details: https://dochub.mongodb.org/core/pymongo-fork-deadlock)osgetpidr   sysversion_info_pymongo_dirwarningswarnr   r   valuesr   r   reset_ensure_opened)r   pidkwargsservers   &   r=   r   Topology.open   s     iik99IIII#w..@&*MM  	 "mm224FLLN 5 ""((*  ZZZ! Z  ZZs   AD=D+D(	+D<	c                   V ^8  d   QhRR/# )r7   r9   floatr;   )r<   s   "r=   r>   rM     s      e r?   c                	d    \         P                  ! 4       pVf   V P                  P                  # V# r[   )r
   	remainingrt   server_selection_timeout)r   timeouts   & r=   get_server_selection_timeout%Topology.get_server_selection_timeout  s(    //#?>>:::r?   Nc               4    V ^8  d   QhRRRRRRRRR	R
RRRR/# )r7   selector Callable[[Selection], Selection]	operationstrr   Optional[float]addressOptional[_Address]operation_idOptional[int]deprioritized_serversOptional[list[Server]]r9   zlist[Server]r;   )r<   s   "r=   r>   rM     sP     - -2- - #2	-
 $- $-  6- 
-r?   c                   Vf   V P                  4       pMTp\        '       g#   V P                  '       d   V P                  4        V P                  ;_uu_ 4        V P                  VVVVVVR7      pV U	u. uF,  p	\        \        V P                  V	P                  4      4      NK.  	  up	uuRRR4       # u up	i   + '       g   i     R# ; i)a2  Return a list of Servers matching selector, or time out.

:param selector: function that takes a list of Servers and returns
    a subset of them.
:param operation: The name of the operation that the server is being selected for.
:param server_selection_timeout: maximum seconds to wait.
    If not provided, the default value common.SERVER_SELECTION_TIMEOUT
    is used.
:param address: optional server address to select.

Calls self.open() if needed.

Raises exc:`ServerSelectionTimeoutError` after
`server_selection_timeout` if no matching servers are found.
N)r   )
r   r   r   cleanup_monitorsr   _select_servers_loopr	   r,   get_server_by_addressr   )
r   r   r   r   r   r   r   server_timeoutr   sds
   &&&&&&&   r=   select_serversTopology.select_servers  s    0 $+!>>@N5N xD///!!#ZZZ"&";";&; #< # PcObVT77

CDOb Z ZZs   B:62B5(B:5B::C	c               4    V ^8  d   QhRRRRRRRRR	R
RRRR/# )r7   r   r   r   r   r   r   r   r   r   r   r   r   r9   list[ServerDescription]r;   )r<   s   "r=   r>   rM   7  sY     P# P#2P# P# 	P#
 $P# $P#  6P# 
!P#r?   c                   \         P                  ! 4       pWr,           pRp	\        P                  ! \        P
                  4      '       dM   \        \        \        P                  VVVV P                  V P                  P                  P                  R7       V P                  P                  TTV P                  P                  V'       d   V U
u. uF  qP                  NK  	  up
MRR7      pV'       Eg   V^ 8X  g   Wx8  d   \        P                  ! \        P
                  4      '       d]   \        \        \        P                   VVVV P                  V P                  P                  P                  V P#                  V4      R7       \%        V P#                  V4       RV RV P                  : 24      hV	'       gz   \        \        \        P&                  VVVV P                  V P                  P                  P                  \)        RV\         P                  ! 4       ,
          ,          4      R	7       R
p	V P+                  4        V P-                  4        \/        V P0                  \2        P4                  4       V P                  P7                  4        \         P                  ! 4       pV P                  P                  WV P                  P                  R7      pEK  V P                  P7                  4        V# u up
i )z7select_servers() guts. Hold the lock when calling this.F)rQ   r   r   operationIdtopologyDescriptionclientIdN)custom_selectorr   )rQ   r   r   r   r   r   failurez, Timeout: zs, Topology Description: i  )rQ   r   r   r   r   r   remainingTimeMST)r   )time	monotonicr   rn   ro   rp   r   r   STARTEDdescription_topology_settingsrc   rx   apply_selectorrt   server_selectorFAILED_error_messager   WAITINGintr   _request_check_allr   r   r   r   check_compatible)r   r   r   r   r   r   r   nowend_timelogged_waitingr   r   s   &&&&&&&     r=   r   Topology._select_servers_loop7  sa    nn=#00??(5==!#($($4$4))<<II #//>> NN::$ EZ"ZDY&#5#5DY"Z ? 
 &%!|s~+88GG0 = D D!)"+$0,0,<,<!%!1!1!D!D!Q!Q $ 3 3H =	 2**845[	Ibcgcscsbvw  ",9AA%' ,(,(8(8!--@@MM$'4>>;K0K(L$M	 "&!##% t(E(EF..0.."C"&"3"3"B"B4>>3Q3Q #C # 	**,""g #[s   K9c               4    V ^8  d   QhRRRRRRRRR	R
RRRR/# r7   r   r   r   r   r   r   r   r   r   r   r   r   r9   r,   r;   )r<   s   "r=   r>   rM     sP      2  #2	
 $  6 $ 
r?   c                	    V P                  VVVVVV4      p\        V4      ^8X  d
   V^ ,          # \        P                  ! V^4      w  rVP                  P
                  V	P                  P
                  8:  d   V# V	# )   )r   lenrandomsamplepooloperation_count)
r   r   r   r   r   r   r   serversserver1server2s
   &&&&&&&   r=   _select_serverTopology._select_server  sw     %%$!
 w<11:!==!4<<''7<<+G+GGNNr?   c               4    V ^8  d   QhRRRRRRRRR	R
RRRR/# r   r;   )r<   s   "r=   r>   rM     sP        2    #2	 
 $   6  $  
 r?   c                   V P                  VVVVVVR7      p\        P                  ! 4       '       d+   \        P                  ! VP                  P
                  4       \        P                  ! \        P                  4      '       d   \        \        \        P                  VVVV P                  V P                  P                  P                  VP                  P                  ^ ,          VP                  P                  ^,          R7	       V# )zALike select_servers, but choose a random server if several match.r   )rQ   r   r   r   r   r   rV   rW   )r   r
   get_timeoutset_rttr   min_round_trip_timer   rn   ro   rp   r   r   	SUCCEEDEDr   rc   r   )r   r   r   r   r   r   r   r   s   &&&&&&& r=   select_serverTopology.select_server  s     $$$!% % 
 MM&,,@@A#00??(5??!#($($4$4))<<II!--55a8!--55a8
 r?   c          
     ,    V ^8  d   QhRRRRRRRRRR	/# )
r7   r   r5   r   r   r   r   r   r9   r,   r;   )r<   s   "r=   r>   rM     s<     
 

 
 #0	

 $
 

r?   c                6    V P                  \        VVVVR7      # )a  Return a Server for "address", reconnecting if necessary.

If the server's type is not known, request an immediate check of all
servers. Time out after "server_selection_timeout" if the server
cannot be reached.

:param address: A (host, port) pair.
:param operation: The name of the operation that the server is being selected for.
:param server_selection_timeout: maximum seconds to wait.
    If not provided, the default value
    common.SERVER_SELECTION_TIMEOUT is used.
:param operation_id: The unique id of the current operation being performed. Defaults to None if not provided.

Calls self.open() if needed.

Raises exc:`ServerSelectionTimeoutError` after
`server_selection_timeout` if no matching servers are found.
r   )r   r#   )r   r   r   r   r   s   &&&&&r=   select_server_by_address!Topology.select_server_by_address  s+    2 !!$% " 
 	
r?   c               (    V ^8  d   QhRRRRRRRR/# r7   server_descriptionr!   
reset_poolr:   interrupt_connectionsr9   r   r;   )r<   s   "r=   r>   rM     s8     E% E%-E% E%  $	E%
 
E%r?   c           	     V   V P                   pVP                  VP                  ,          p\        WQ4      '       d   R# \	        V P                   V4      pVP
                  '       g2   VP                  '       dg   VP                  \        P                  8X  dH   V P                  P                  VP                  4      pV'       d   VP                  P                  4        WQ8H  pV P                  '       dq   V'       gi   V P                  f   Q hV P                   f   Q hV P                  P#                  V P                   P$                  WQVP                  V P&                  334       W`n         V P)                  4        V P*                  '       dp   V'       gh   V P                  f   Q hV P                   f   Q hV P                  P#                  V P                   P,                  W@P                   V P&                  334       \.        P0                  ! \2        P4                  4      '       dQ   V'       gI   \7        \.        \8        P:                  V P&                  \=        V4      \=        V P                   4      R7       V P>                  '       d   VP                  \        P@                  8X  dk   V P                   P                  \B        9  dL   V P>                  PE                  4        \F        '       g&   V PH                  PK                  V P>                  4       V PL                  PO                  4        R# )zYProcess a new ServerDescription on an opened topology.

Hold the lock when calling this.
NrS   )(rx   _server_descriptionsr   _is_stale_server_descriptionr1   is_readableis_server_type_knowntopology_typer.   Singler   getr   readyrh   rk   rf   rr   "publish_server_description_changedrc   _update_serversrj   rz   r   rn   ro   rp   r   r   r{   r|   r   ry   r-   r   r   r   appendr   
notify_all)	r   r  r	  r
  td_oldsd_oldnew_tdr   suppress_events	   &&&&     r=   _process_changeTopology._process_change  sQ    "",,-?-G-GH'CC-d.?.?AST)))3338L8LP]PdPd8d]]&&'9'A'ABF!!#5<<+++??...LLOOFF1C1K1KTM^M^_ #N<<+++??...LLOOHH..0A0AB $$W]]33N*::,,$(L#D$5$56   M$9$99!!//7MM##%8##**4+<+<= 	""$r?   c               (    V ^8  d   QhRRRRRRRR/# r  r;   )r<   s   "r=   r>   rM   ,  s8     O O-O O  $	O
 
Or?   c                   V P                   ;_uu_ 4        V P                  '       d>   V P                  P                  VP                  4      '       d   V P                  WV4       RRR4       V'       dN   V P                  P                  VP                  4      pV'       d   VP                  P                  VR7       R# R# R#   + '       g   i     Lg; i)z>Process a new ServerDescription after an hello call completes.N)r
  )
r   r   rx   
has_serverr   r  r   r  r   r   )r   r  r	  r
  r   s   &&&& r=   	on_changeTopology.on_change,  s     ZZZ ||| 1 1 < <=O=W=W X X$$%7EZ[  ]]&&'9'A'ABF!!8M!N   Zs   =CCC	c                    V ^8  d   QhRRRR/# r7   seedlistzlist[tuple[str, Any]]r9   r   r;   )r<   s   "r=   r>   rM   E  s      ,A d r?   c           	     |   V P                   pVP                  \        9  d   R# \        V P                   V4      V n         V P	                  4        V P
                  '       dh   V P                  f   Q hV P                  f   Q hV P                  P                  V P                  P                  W P                   V P                  334       \        P                  ! \        P                  4      '       dK   \        \        \         P"                  V P                  \%        V4      \%        V P                   4      R7       R# R# )zOProcess a new seedlist on an opened topology.
Hold the lock when calling this.
NrS   )rx   r  r-   r0   r  rj   rk   rf   rr   rz   rc   r   rn   ro   rp   r   r   r{   r|   )r   r%  r  s   && r=   _process_srv_updateTopology._process_srv_updateE  s     ""'==EdFWFWYab<<+++??...LLOOHH..0A0AB $$W]]33*::,,$(L#D$5$56 4r?   c                    V ^8  d   QhRRRR/# r$  r;   )r<   s   "r=   r>   rM   b  s     3 3&; 3 3r?   c                    V P                   ;_uu_ 4        V P                  '       d   V P                  V4       RRR4       R#   + '       g   i     R# ; i)z?Process a new list of nodes obtained from scanning SRV records.N)r   r   r'  )r   r%  s   &&r=   on_srv_updateTopology.on_srv_updateb  s0     ZZZ|||((2 ZZZs   $AA	c                    V ^8  d   QhRRRR/# )r7   r   r5   r9   zOptional[Server]r;   )r<   s   "r=   r>   rM   i  s     * *X *:J *r?   c                8    V P                   P                  V4      # )a"  Get a Server or None.

Returns the current version of the server immediately, even if it's
Unknown or absent from the topology. Only use this in unittests.
In driver code, use select_server_by_address, since then you're
assured a recent view of the server's type and wire protocol version.
)r   r  r   r   s   &&r=   r   Topology.get_server_by_addressi  s     }}  ))r?   c                    V ^8  d   QhRRRR/# )r7   r   r5   r9   r:   r;   )r<   s   "r=   r>   rM   s  s     ( (( (t (r?   c                	    WP                   9   # r[   )r   r/  s   &&r=   r   Topology.has_servers  s    --''r?   c                   V ^8  d   QhRR/# )r7   r9   r   r;   )r<   s   "r=   r>   rM   v  s     N N/ Nr?   c                (   V P                   ;_uu_ 4        V P                  P                  pV\        P                  8w  d    RRR4       R# \        V P                  4       4      ^ ,          P                  uuRRR4       #   + '       g   i     R# ; i)z!Return primary's address or None.N)r   rx   r  r.   ReplicaSetWithPrimaryr&   _new_selectionr   )r   r  s   & r=   get_primaryTopology.get_primaryv  s`     ZZZ --;;M C CC Z
 ,D,?,?,AB1EMM ZZZs   -B )B  B	c                    V ^8  d   QhRRRR/# )r7   r   r   r9   set[_Address]r;   )r<   s   "r=   r>   rM     s      P P1Q PVc Pr?   c                   V P                   ;_uu_ 4        V P                  P                  pV\        P                  \        P
                  39  d   \        4       uuRRR4       # \        V! V P                  4       4      4       Uu0 uF  q3P                  kK  	  upuuRRR4       # u upi   + '       g   i     R# ; i)z+Return set of replica set member addresses.N)
r   rx   r  r.   r6  ReplicaSetNoPrimarysetiterr7  r   )r   r   r  r   s   &&  r=   _get_replica_set_members!Topology._get_replica_set_members  s     ZZZ --;;M3311%  u Z *.ht7J7J7L.M)NO)N2JJ)NO Z P ZZs$   AB,%!B,B'B,'B,,B=	c                   V ^8  d   QhRR/# r7   r9   r;  r;   )r<   s   "r=   r>   rM     s     H H Hr?   c                ,    V P                  \        4      # )z"Return set of secondary addresses.)r@  r%   r   s   &r=   get_secondariesTopology.get_secondaries  s    ,,-FGGr?   c                   V ^8  d   QhRR/# rC  r;   )r<   s   "r=   r>   rM     s     F Fm Fr?   c                ,    V P                  \        4      # )z Return set of arbiter addresses.)r@  r$   rE  s   &r=   get_arbitersTopology.get_arbiters  s    ,,-DEEr?   c                   V ^8  d   QhRR/# )r7   r9   zOptional[ClusterTime]r;   )r<   s   "r=   r>   rM     s     & &"7 &r?   c                    V P                   # )z1Return a document, the highest seen $clusterTime.r   rE  s   &r=   max_cluster_timeTopology.max_cluster_time  s    %%%r?   c                    V ^8  d   QhRRRR/# r7   cluster_timeOptional[Mapping[str, Any]]r9   r   r;   )r<   s   "r=   r>   rM     s     6 6:U 6Z^ 6r?   c                	    V'       d<   V P                   '       d    VR ,          V P                   R ,          8  d	   Wn         R# R# R# )clusterTimeNrN  r   rS  s   &&r=   _receive_cluster_time_no_lock&Topology._receive_cluster_time_no_lock  s>      ***.1G1G1VV)5& W	 r?   c                    V ^8  d   QhRRRR/# rR  r;   )r<   s   "r=   r>   rM     s     = =1L =QU =r?   c                	    V P                   ;_uu_ 4        V P                  V4       R R R 4       R #   + '       g   i     R # ; ir[   )r   rX  rW  s   &&r=   receive_cluster_timeTopology.receive_cluster_time  s%    ZZZ..|< ZZZ	   1A	c                    V ^8  d   QhRRRR/# )r7   	wait_timer   r9   r   r;   )r<   s   "r=   r>   rM     s     3 33 3t 3r?   c                    V P                   ;_uu_ 4        V P                  4        \        V P                  V4       RRR4       R#   + '       g   i     R# ; i)z=Wake all monitors, wait for at least one to check its server.N)r   r   r   r   )r   r`  s   &&r=   request_check_allTopology.request_check_all  s1    ZZZ##%t	2 ZZZs   'AA	c                   V ^8  d   QhRR/# )r7   r9   r   r;   )r<   s   "r=   r>   rM     s     2 2&= 2r?   c                    V P                   P                  \        P                  8X  d   V P                   P                  # V P                   P
                  # )znReturn a list of all data-bearing servers.

This includes any server that might be selected for an operation.
)rx   r  r.   r  known_serversreadable_serversrE  s   &r=   data_bearing_serversTopology.data_bearing_servers  sB    
 **m.B.BB$$222  111r?   c                   V ^8  d   QhRR/# r   r;   )r<   s   "r=   r>   rM     s      T r?   c           	     	   . pV P                   ;_uu_ 4        V P                  4        FT  pV P                  VP                  ,          pVP	                  W3P
                  P                  P                  4       34       KV  	  R R R 4       V F!  w  r4 VP
                  P                  V4       K#  	  R #   + '       g   i     L9; i  \         d<   p\        T^ TRR 4      pT P                  TP                  P                  T4       h R p?ii ; i)NF)r   rh  r   r   r  r   genget_overallremove_stale_socketsr   _ErrorContexthandle_errorr   )r   r   r   r   
generationexcctxs   &      r=   update_poolTopology.update_pool  s    ZZZ//1rzz2(C(C(EFG 2  #*F00< #* Z   #CJtD!!&"4"4"<"<cBs$   A)B1C1C	D
6DD
c                   V ^8  d   QhRR/# r   r;   )r<   s   "r=   r>   rM     s     B< B<t B<r?   c           	        V P                   ;_uu_ 4        V P                  pV P                  P                  4        FF  pVP	                  4        \
        '       d   K!  V P                  P                  VP                  4       KH  	  V P                  P                  4       V n        V P                  P                  4       P                  4        F.  w  r4W0P                  9   g   K  W@P                  V,          n        K0  	  V P                  '       dL   V P                  P	                  4        \
        '       g&   V P                  P                  V P                  4       RV n        RV n        RRR4       V P                   '       Ed   V P"                  f   Q hV P$                  f   Q h\'        \(        P*                  / V P                  P,                  V P                  P.                  V P                  P0                  V P                  P2                  4      V n        V P"                  P5                  V P$                  P6                  XV P                  V P8                  334       V P"                  P5                  V P$                  P:                  V P8                  334       \<        P>                  ! \@        PB                  4      '       ds   \E        \<        \F        PH                  V P8                  \K        X4      \K        V P                  4      R7       \E        \<        \F        PL                  V P8                  R7       V PN                  '       g   V P                   '       da   V PP                  P	                  4        V PP                  PS                  ^4       \U        \V        PX                  ! V P"                  4      4       R# R#   + '       g   i     EL]; i)zClear pools and terminate monitors. Topology does not reopen on
demand. Any further operations will raise
:exc:`~.errors.InvalidOperation`.
FTNrS   rP   )-r   rx   r   r   r   r   r   r  _monitorr   r   itemsr   r   r   r   rj   rk   rf   r/   r.   ry   rw   max_set_versionmax_election_idr   rr   rz   rc   publish_topology_closedr   rn   ro   rp   r   r   r{   r|   STOP_TOPOLOGYrh   rl   joinrH   r   r   )r   old_tdr   r   r   s   &    r=   r   Topology.close  s   
 ZZZ&&F--..0x''..v? 1 !% 1 1 7 7 9D#00DDFLLNmm+9;MM'*6  O
    !!'')x''..t/@/@A DLDL) . <<+++??... 3%%!!22!!11!!11!!44!D LLOOHH))))	 LLdooEEHYHYG[\]$$W]]33*::,,$(L#D$5$56 &8&F&FSWSdSd 4#3#3#3""((*""''* T\\!:;	 $4s ZZs%   AN>BN>$,N>%N>73N>>O	c                   V ^8  d   QhRR/# )r7   r9   r/   r;   )r<   s   "r=   r>   rM     s     ! !0 !r?   c                	    V P                   # r[   )rx   rE  s   &r=   r   Topology.description  s       r?   c                   V ^8  d   QhRR/# )r7   r9   zlist[_ServerSession]r;   )r<   s   "r=   r>   rM     s     , ,"6 ,r?   c                6    V P                   P                  4       # )z"Pop all session ids from the pool.)r   pop_allrE  s   &r=   pop_all_sessionsTopology.pop_all_sessions  s    !!))++r?   c                    V ^8  d   QhRRRR/# )r7   session_timeout_minutesr   r9   r'   r;   )r<   s   "r=   r>   rM     s     N N- NN Nr?   c                8    V P                   P                  V4      # )z>Start or resume a server session, or raise ConfigurationError.)r   get_server_session)r   r  s   &&r=   r  Topology.get_server_session  s    !!445LMMr?   c                    V ^8  d   QhRRRR/# )r7   server_sessionr'   r9   r   r;   )r<   s   "r=   r>   rM     s     A AN At Ar?   c                	<    V P                   P                  V4       R # r[   )r   return_server_session)r   r  s   &&r=   r  Topology.return_server_session  s    00@r?   c                   V ^8  d   QhRR/# )r7   r9   r"   r;   )r<   s   "r=   r>   rM     s     F F	 Fr?   c                B    \         P                  ! V P                  4      # )z]A Selection object, initially including all known servers.

Hold the lock when calling this.
)r"   from_topology_descriptionrx   rE  s   &r=   r7  Topology._new_selection  s    
 2243D3DEEr?   c                   V ^8  d   QhRR/# r   r;   )r<   s   "r=   r>   rM   &  s       r?   c                   V P                   '       d   \        R4      hV P                  '       Eg   RV n        V P                  4        V P                  '       g   V P
                  '       d   V P                  P                  4        V P                  '       d:   V P                  P                  \        9   d   V P                  P                  4        V P                  P                  '       dF   V P                  \        V P                   ^ ,          \#        R^RV P$                  R^/4      4      4       V P&                  P)                  4        F  pVP                  4        K  	  R# )zKStart monitors, or restart after a fork.

Hold the lock when calling this.
z"Cannot use MongoClient after closeTok	serviceIdmaxWireVersionN)r   r   r   r  rj   rh   rl   r   r   r   r  r-   rt   r   r  r!   r   r   rc   r   r   r   r   s   & r=   r   Topology._ensure_opened&  s   
 <<<"#GHH|||DL  " 4#7#7#7&&++-    d&6&6&D&DH^&^!!&&(~~+++$$%,,Q/tQT5F5FHXZ\]^ mm**,FKKM -r?   c               $    V ^8  d   QhRRRRRR/# )r7   r   r5   err_ctxro  r9   r:   r;   )r<   s   "r=   r>   rM   G  s&     B Bx B- BD Br?   c                	   V P                   P                  V4      pVf   R# VP                  P                  VP                  VP
                  4      '       d   R# VP                  P                  pVP                  pR pV'       dN   \        VR4      '       d<   \        VP                  \        4      '       d   VP                  P                  R4      p\        WF4      # )NTdetailstopologyVersion)r   r  _poolstale_generationsock_generation
service_idr   topology_versionerrorhasattr
isinstancer  dict _is_stale_error_topology_version)r   r   r  r   cur_tvr  error_tvs   &&&    r=   _is_stale_errorTopology._is_stale_errorG  s    ""7+><<(()@)@'BTBTUU ##44WUI..%--.. ==,,->?/AAr?   c               $    V ^8  d   QhRRRRRR/# r7   r   r5   r  ro  r9   r   r;   )r<   s   "r=   r>   rM   [  s&     D+ D+X D+ D+$ D+r?   c                	   V P                  W4      '       d   R # V P                  V,          pVP                  pVP                  pV P                  P
                  '       d   V'       g   VP                  '       g   R # \        V\        4      '       d   VP                  '       d   R # \        V\        4      '       d   R # \        V\        \        34      '       EdO   \        VR4      '       d   VP                  pM6\        V\        4      '       d   RMR pVP                  P                  RV4      pV\         P"                  9   d   V\         P$                  9   pV P                  P
                  '       g   V P'                  \)        WR7      4       V'       g   VP*                  ^8:  d   VP-                  V4       VP/                  4        R # VP                  '       gK   V P                  P
                  '       g   V P'                  \)        WR7      4       VP-                  V4       R # R # \        V\0        4      '       d   \        V\2        4      '       g   VP5                  R4      '       d   R # V P                  P
                  '       g   V P'                  \)        WR7      4       VP-                  V4       VP6                  P9                  4        R # R # )Ncodei{'  r  SystemOverloadedError)r  r   r  r  rt   r   completed_handshaker  r   r   r   r   r  r  r  r  r   _NOT_PRIMARY_CODES_SHUTDOWN_CODESr  r!   max_wire_versionr   request_checkr   r   has_error_labelrx  cancel_check)	r   r   r  r   r  r  err_codedefaultis_shutting_downs	   &&&      r=   _handle_errorTopology._handle_error[  s   11w'''
 >>'''
7C^C^C^e^,,1L1L1L
 z**1ABCC uf%% :: $.e_#E#E%4 ==,,VW=><<<#+~/M/M#M ~~333(():7)PQ#(@(@A(ELL,$$&000~~333(():7)PQZ( 1 011%!677%%&=>> >>///$$%6w%LMLL$ OO((* 2r?   c               $    V ^8  d   QhRRRRRR/# r  r;   )r<   s   "r=   r>   rM     s!     1 1H 1} 1 1r?   c                    V P                   ;_uu_ 4        V P                  W4       RRR4       R#   + '       g   i     R# ; i)zHandle an application error.

May reset the server to Unknown, clear the pool, and request an
immediate check depending on the error and the context.
N)r   r  )r   r   r  s   &&&r=   rp  Topology.handle_error  s'     ZZZw0 ZZZr^  c                   V ^8  d   QhRR/# r   r;   )r<   s   "r=   r>   rM     s     # #D #r?   c                h    V P                   P                  4        F  pVP                  4        K  	  R# )z3Wake all monitors. Hold the lock when calling this.N)r   r   r  r  s   & r=   r   Topology._request_check_all  s%    mm**,F  " -r?   c                   V ^8  d   QhRR/# r   r;   )r<   s   "r=   r>   rM     s     *+ *+ *+r?   c           
        V P                   P                  4       P                  4        EFk  w  rWP                  9  d   V P                  P                  VV V P                  V4      V P                  R7      pRpV P                  '       d/   V P                  e!   \        P                  ! V P                  4      p\        VV P                  V4      VV P                  V P                  VR7      pWPP                  V&   VP                  4        K  V P                  V,          P                   P"                  pW P                  V,          n        WbP"                  8w  g   EK5  V P                  V,          P$                  P'                  VP"                  4       EKn  	  \)        V P                  P                  4       4       F  w  rV P                   P+                  V4      '       d   K(  VP-                  4        \.        '       g&   V P0                  P3                  VP4                  4       V P                  P7                  V4       K  	  R# )zbSync our Servers from TopologyDescription.server_descriptions.

Hold the lock while calling this.
)r  topologyr   rL   N)r  r   monitortopology_id	listenersevents)rx   r   ry  r   rt   monitor_class_create_pool_for_monitorrh   rk   r   r   r,   _create_pool_for_serverrc   rf   r   r   is_writabler   update_is_writabler   r   r   r   r   r  rx  pop)r   r   r   r  r\   r   was_writables   &      r=   r  Topology._update_servers  s   
  ,,@@BHHJKGmm+..66')!66w?&*nn	 7  '''DLL,D";;t||4D')55g># $ 1 1"oo *0g&  $}}W5AAMM57g&2>>1MM'*//BB2>>R= K@  $DMM$7$7$9:OG$$//88x''..v?!!'*  ;r?   c                    V ^8  d   QhRRRR/# r7   r   r5   r9   r+   r;   )r<   s   "r=   r>   rM     s     
 
x 
D 
r?   c                	x    V P                   P                  WP                   P                  V P                  R 7      # ))	client_id)rt   
pool_classpool_optionsrc   r/  s   &&r=   r   Topology._create_pool_for_server  s3    ~~((^^00D<M<M ) 
 	
r?   c                    V ^8  d   QhRRRR/# r  r;   )r<   s   "r=   r>   rM     s     
 
 
T 
r?   c                	F   V P                   P                  p\        VP                  VP                  VP                  VP
                  VP                  VP                  VP                  R VP                  R7	      pV P                   P                  WRV P                  R7      # )F)	connect_timeoutsocket_timeoutssl_contexttls_allow_invalid_hostnamesevent_listenersappnamedriverpause_enabled
server_apiT)is_sdamr  )rt   r  r    r  _ssl_contextr  re   r  r  r  r  rc   )r   r   optionsmonitor_pool_optionss   &&  r=   r  !Topology._create_pool_for_monitor  s    ..--
  +#33"22,,(/(K(K#44OO>>))
 
 ~~((44CTCT ) 
 	
r?   c                    V ^8  d   QhRRRR/# )r7   r   r   r9   r   r;   )r<   s   "r=   r>   rM     s     8Y 8Y'G 8YC 8Yr?   c                *  a V P                   P                  \        P                  \        P                  39   pV'       d   RpM.V P                   P                  \        P
                  8X  d   RpMRpV P                   P                  '       d'   V\        J d   V'       d   R# RV,          # RV RV R2# \        V P                   P                  4       4      p\        V P                   P                  4       P                  4       4      pV'       g8   V'       d'   R	P                  VV P                  P                  4      # R
V,          # V^ ,          P                  o\        ;QJ d&    V3R lVR,           4       F  '       d   K   RM	  RM! V3R lVR,           4       4      pV'       dT   Sf
   RV,          # V'       d4   \!        V4      P#                  V P$                  4      '       g
   RV,          # \'        S4      # RP)                  R V 4       4      # )zUFormat an error message if server selection fails.

Hold the lock when calling this.
zreplica set membersmongosesr   zNo primary available for writeszNo %s available for writeszNo z match selector ""z)No {} available for replica set name "{}"zNo %s availablec              3  @   <"   T F  qP                   S8H  x  K  	  R # 5ir[   r  ).0r   r  s   & r=   	<genexpr>*Topology._error_message.<locals>.<genexpr>  s     G;||u,;s   :r   NNFTzNo %s found yetz\Could not reach any servers in %s. Replica set is configured with internal hostnames or IPs?,c              3  r   "   T F-  qP                   '       g   K  \        VP                   4      x  K/  	  R # 5ir[   )r  r   )r  r   s   & r=   r  r  .  s#     Xf<< 1FLL 1 1s   77)rx   r  r.   r6  r=  Shardedrf  r&   r   r   r   r<   rt   rw   r  allr>  intersectionr   r   r~  )r   r   is_replica_setserver_plural	addressesr   samer  s   &&     @r=   r   Topology._error_message  s   
 **88//--=
 

 1M,,0E0EE&M%M***33!<7-GG]O+<XJaHHT..BBDEI4,,@@BIIKLG!FMM%77 
 -}<< AJ$$E3G72;G333G72;GGD=,}<<!#i.*E*EdFZFZ*[*[FHQR
 5z!xxXXXXr?   c                   V ^8  d   QhRR/# r   r;   )r<   s   "r=   r>   rM   0  s     K K$ Kr?   c                	   . p V P                   '       d,   VP                  V P                   P                  4       4       K=   \        P
                  ! V Uu. uF  q"P                  4       NK  	  upR R/  R#   \         d     LBi ; iu upi )return_exceptionsTN)r   r  r  
IndexErrorasynciogatherr~  )r   tasksts   &  r=   r   Topology.cleanup_monitors0  st    	%%%T004467 & 	515a51JTJ  		1s   A7 +A7 B7BBc                   V ^8  d   QhRR/# )r7   r9   r   r;   )r<   s   "r=   r>   rM   9  s     I I# Ir?   c                	    R pV P                   '       g   RpRV P                  P                   RV V P                  : R2# ) zCLOSED < >)r   	__class____name__rx   )r   msgs   & r=   __repr__Topology.__repr__9  s@    |||C4>>**+1SE$2C2C1FaHHr?   c                   V ^8  d   QhRR/# )r7   r9   z>tuple[tuple[_Address, ...], Optional[str], Optional[str], str]r;   )r<   s   "r=   r>   rM   ?  s     \ \X \r?   c                    V P                   p\        \        VP                  4      4      VP                  VP
                  VP                  3# )z?The properties to use for MongoClient/Topology equality checks.)rt   tuplesortedr}   rw   r   srv_service_name)r   tss   & r=   eq_propsTopology.eq_props?  s8    ^^fRXX&')<)<bggrGZGZ[[r?   c                    V ^8  d   QhRRRR/# )r7   otherobjectr9   r:   r;   )r<   s   "r=   r>   rM   D  s      F t r?   c                	    \        WP                  4      '       d"   V P                  4       VP                  4       8H  # \        # r[   )r  r  r  NotImplemented)r   r  s   &&r=   __eq__Topology.__eq__D  s/    e^^,,==?enn&666r?   c                   V ^8  d   QhRR/# )r7   r9   r   r;   )r<   s   "r=   r>   rM   I  s     % %# %r?   c                	4    \        V P                  4       4      # r[   )hashr  rE  s   &r=   __hash__Topology.__hash__I  s    DMMO$$r?   )__events_executorr   r   rx   rk   rf   r   r   r   r   r   rh   rj   r   r   r   rt   r   rc   )NNNNr[   )NN)FF)   )3r  
__module____qualname____firstlineno____doc__r   r   r   r   r   r   r   r  r  r!  r'  r+  r   r   r8  r@  rF  rJ  rO  rX  r\  rb  rh  rt  r   propertyr   r  r  r  r7  r   r  r  rp  r   r  r  r  r   r   r  r  r"  r'  __static_attributes__r;   r?   r=   rJ   rJ   h   s   4m4^%"N-^P#d2 D
BE%NO2:3*(NPHF&6=32"B<H ! !,NAFBB(D+L1#
*+X


,8YtKI\

% %r?   rJ   c                  &    ] tR tRtRtR R ltRtR# )ro  iM  z.An error with context for SDAM error handling.c          
     ,    V ^8  d   QhRRRRRRRRRR	/# )
r7   r  BaseExceptionr  r   r  r  r:   r  zOptional[ObjectId]r;   )r<   s   "r=   r>   _ErrorContext.__annotate__P  s<     % %% % 	%
 "% '%r?   c                	B    Wn         W n        W0n        W@n        WPn        R # r[   )r  r  r  r  r  )r   r  r  r  r  r  s   &&&&&&r=   r   _ErrorContext.__init__P  s      
 0.#6 $r?   )r  r  r  r  r  N)r  r+  r,  r-  r.  r   r0  r;   r?   r=   ro  ro  M  s    8% %r?   ro  c               $    V ^8  d   QhRRRRRR/# )r7   
current_tvrT  r  r9   r:   r;   )r<   s   "r=   r>   r>   _  s$     8 8+87R8	8r?   c                j    V e   Vf   R# V R,          VR,          8w  d   R# V R,          VR,          8  # )z9Return True if the error's topologyVersion is <= current.F	processIdcounterr;   )r8  r  s   &&r=   r  r  _  s<     X-+(;"77i HY$777r?   c               $    V ^8  d   QhRRRRRR/# )r7   
current_sdr!   new_sdr9   r:   r;   )r<   s   "r=   r>   r>   j  s$     5 5-> 5HY 5^b 5r?   c                    V P                   VP                   r2Ve   Vf   R# VR,          VR,          8w  d   R# VR,          VR,          8  # )z4Return True if the new topologyVersion is < current.Fr:  r;  )r  )r=  r>  r8  new_tvs   &&  r=   r  r  j  sL    #44f6M6MV^+&"55i 6)#444r?   )[r.  
__future__r   r  ro   r   rB   r   r   r   r   r   pathlibr   typingr   r   r   r   r   r	   pymongor
   r   r   r   pymongo.errorsr   r   r   r   r   r   r   r   r   pymongo.hellor   pymongo.lockr   r   r   pymongo.loggerr   r   r   r   r   pymongo.pool_optionsr    pymongo.server_descriptionr!   pymongo.server_selectorsr"   r#   r$   r%   r&   "pymongo.synchronous.client_sessionr'   r(   pymongo.synchronous.monitorr)   r*   pymongo.synchronous.poolr+   pymongo.synchronous.serverr,   pymongo.topology_descriptionr-   r.   r/   r0   r1   bsonr2   pymongo.synchronous.settingsr3   pymongo.typingsr4   r5   r   r   __file__parentr   rH   rJ   ro  r  r  r;   r?   r=   <module>rV     s    C "   	   
     H H D D
 
 
   
  - 8  R ? ) -  =54>(()"b% b%J% %$85r?   