+
    8icM                    
   R t ^ RIHt ^ RIt^ RIt^ RIt^ RIt^ RIt^ RIH	t	H
t
Ht ^ RIHtHt ^ RIHt ^ RIHtHt ^ RIHt ^ RIHt ^ R	IHtHtHt ^ R
IHt ^ RIHt ^ RI H!t! ^ RI"H#t# ^ RI$H%t% ]	'       d   ^ RI&H't'H(t(H)t) ^ RI*H+t+ ^ RI,H-t- Rt.R R lt/R R lt0 ! R R4      t1 ! R R]14      t2 ! R R]14      t3 ! R R]14      t4]5! 4       t6R R  lt7R! R" lt8R# R$ lt9R% R& lt:].'       d   ]Pv                  ! ]:4       R# R# )'z9Class to monitor a MongoDB server on a background thread.)annotationsN)TYPE_CHECKINGAnyOptional)commonperiodic_executor)MovingMinimum)NetworkTimeout_OperationCancelled)Hello)_create_lock)_SDAM_LOGGER
_debug_log_SDAMStatusMessage)_shutdown_executors)_is_faas)MovingAverage)ServerDescription)_SrvResolver)
ConnectionPool_CancellationContext)TopologySettings)TopologyTc                    V ^8  d   QhRRRR/# )   error	ExceptionreturnNone )formats   "Y/var/www/html/photoedit/myenv/lib/python3.14/site-packages/pymongo/synchronous/monitor.py__annotate__r#   2   s      Y 4     c                0    RV n         RV n        RV n        R# )z'PYTHON-2433 Clear error traceback info.N)__traceback____context__	__cause__r   s   &r"   	_sanitizer*   2   s    EEEOr$   c                    V ^8  d   QhRRRR/# )r   startfloatr   r    )r!   s   "r"   r#   r#   9   s     . .u . .r$   c                N    \        R\        P                  ! 4       V ,
          4      # )zReturn the duration since the given start time.

Accounts for buggy platforms where time.monotonic() is not monotonic.
See PYTHON-4600.
g        )maxtime	monotonic)r,   s   &r"   _monotonic_durationr2   9   s     sDNN$u,--r$   c                  ^    ] tR t^Bt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t
R# )MonitorBasec               (    V ^8  d   QhRRRRRRRR/# )	r   topologyr   namestrintervalintmin_intervalr-   r    )r!   s   "r"   r#   MonitorBase.__annotate__C   s)              SX  r$   c                   a R V3R llp\         P                  ! W4WRR7      pW`n        RR V3R lllp\        P                  ! WP
                  4      o\        P                  ! W4      V n        \        V 4       R# )zBase class to do periodic work on a background thread.

The background thread is signaled to stop when the Topology or
this instance is freed.
c                   V ^8  d   QhRR/# )r   r   boolr    )r!   s   "r"   r#   *MonitorBase.__init__.<locals>.__annotate__L   s     	 	 	r$   c                 B   < S! 4       p V f   R# V P                  4        R# )NFT)_run)monitorself_refs    r"   target$MonitorBase.__init__.<locals>.targetL   s    jGLLNr$   )r9   r;   rE   r7   Nc                    V ^8  d   QhRRRR/# )r   dummyzOptional[Topology]r   r   r    )r!   s   "r"   r#   r@   Y   s     	( 	(#5 	( 	(r$   c                J   < S! 4       pV'       d   VP                  4        R # R # Ngc_safe_close)rH   rC   rD   s   & r"   _on_topology_gc-MonitorBase.__init__.<locals>._on_topology_gcY   s      jG%%' r$   rJ   )	r   PeriodicExecutor	_executorweakrefrefcloseproxy	_topology	_register)	selfr6   r7   r9   r;   rE   executorrM   rD   s	   &&&&&   @r"   __init__MonitorBase.__init__C   s`    	 	 %55
 "	( 	( ;;t^^4 xA$r$   c                   V ^8  d   QhRR/# r   r   r   r    )r!   s   "r"   r#   r<   e   s      d r$   c                :    V P                   P                  4        R# )zKStart monitoring, or restart after a fork.

Multiple calls have no effect.
N)rP   openrW   s   &r"   r^   MonitorBase.opene   s    
 	r$   c                   V ^8  d   QhRR/# r\   r    )r!   s   "r"   r#   r<   l   s      t r$   c                :    V P                   P                  4        R# )zGC safe close.N)rP   rS   r_   s   &r"   rL   MonitorBase.gc_safe_closel   s    r$   c                   V ^8  d   QhRR/# r\   r    )r!   s   "r"   r#   r<   p   s      t r$   c                &    V P                  4        R# )zGClose and stop monitoring.

open() restarts the monitor after closing.
NrK   r_   s   &r"   rS   MonitorBase.closep   s    
 	r$   c                   V ^8  d   QhRR/# r\   r    )r!   s   "r"   r#   r<   w   s      d r$   c                :    V P                   P                  4        R# )zWait for the monitor to stop.N)rP   joinr_   s   &r"   ri   MonitorBase.joinw       r$   c                   V ^8  d   QhRR/# r\   r    )r!   s   "r"   r#   r<   {   s      t r$   c                :    V P                   P                  4        R# )z)If the monitor is sleeping, wake it soon.N)rP   waker_   s   &r"   request_checkMonitorBase.request_check{   rk   r$   )rP   rU   N)__name__
__module____qualname____firstlineno__rY   r^   rL   rS   ri   ro   __static_attributes__r    r$   r"   r4   r4   B   s&     D r$   r4   c                     a  ] tR t^tR V 3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tV ;t# )Monitorc               (    V ^8  d   QhRRRRRRRR/# )	r   server_descriptionr   r6   r   poolr   topology_settingsr   r    )r!   s   "r"   r#   Monitor.__annotate__   s2     &* &*-&* &* 	&*
 ,&*r$   c                .  < \         SV `  VRVP                  \        P                  4       Wn        W0n        W@n        V P                  P                  P                  V n
        V P                  RJ;'       d    V P                  P                  V n        RV n        RV n        \        VVVP!                  VP"                  4      4      V n        VP&                  R8X  d
   RV n        R# VP&                  R8X  d
   RV n        R# \+        4       '       * V n        R# )zClass to monitor a MongoDB server on a background thread.

Pass an initial ServerDescription, a Topology, a Pool, and
TopologySettings.

The Topology is weakly referenced. The Pool must be exclusive to this
Monitor.
pymongo_server_monitor_threadNstreamTpollF)superrY   heartbeat_frequencyr   MIN_HEARTBEAT_INTERVAL_server_description_pool	_settings_pool_options_event_listeners
_listenersenabled_for_server_heartbeat_publish_cancel_context_conn_id_RttMonitor_create_pool_for_monitoraddress_rtt_monitorserver_monitoring_mode_streamr   )rW   ry   r6   rz   r{   	__class__s   &&&&&r"   rY   Monitor.__init__   s     	+11))		
 $6 
*..66GGt3dd8d8d?C'+'--.@.H.HI

 33x?DL55? DL'z>DLr$   c                   V ^8  d   QhRR/# r\   r    )r!   s   "r"   r#   r|      s      d r$   c                R    V P                   pV'       d   VP                  4        R# R# )ztCancel any concurrent hello check.

Note: this is called from a weakref.proxy callback and MUST NOT take
any locks.
N)r   cancel)rW   contexts   & r"   cancel_checkMonitor.cancel_check   s#     && NN	 r$   c                   V ^8  d   QhRR/# r\   r    )r!   s   "r"   r#   r|      s     & &D &r$   c                    V P                   P                  4        V P                  P                  '       d   V P                   P	                  4        R# R# )z1Start an _RttMonitor that periodically runs ping.N)r   r^   rP   _stoppedrS   r_   s   &r"   _start_rtt_monitorMonitor._start_rtt_monitor   s=    
 	 >>"""##% #r$   c                   V ^8  d   QhRR/# r\   r    )r!   s   "r"   r#   r|      s      t r$   c                	    V P                   P                  4        V P                  P                  4        V P	                  4        R # rJ   )rP   rS   r   rL   r   r_   s   &r"   rL   Monitor.gc_safe_close   s0    '')r$   c                   V ^8  d   QhRR/# r\   r    )r!   s   "r"   r#   r|      s     ` `d `r$   c                	    \         P                  ! V P                  P                  4       V P                  P                  4       R R7       R# )T)return_exceptionsN)asynciogatherrP   ri   r   r_   s   &r"   ri   Monitor.join   s/    t~~**,d.?.?.D.D.FZ^_r$   c                   V ^8  d   QhRR/# r\   r    )r!   s   "r"   r#   r|      s     ! !t !r$   c                	z    V P                  4        V P                  P                  4        V P                  4        R # rJ   )rL   r   rS   _reset_connectionr_   s   &r"   rS   Monitor.close   s.    ! 	 r$   c                   V ^8  d   QhRR/# r\   r    )r!   s   "r"   r#   r|      s      4 r$   c                	:    V P                   P                  4        R # rJ   )r   resetr_   s   &r"   r   Monitor._reset_connection   s    

r$   c                   V ^8  d   QhRR/# r\   r    )r!   s   "r"   r#   r|      s     (* (*d (*r$   c                	    V P                   p V P                  4       V n         T P                  P                  T P                   T P                   P                  \        T P                   P                  \         4      R7       T P"                  '       dc   T P                   P                  '       dG   T P                   P$                  '       d+   T P'                  4        T P                  P                  4        T P                   P                  '       d-   TP                  '       d   T P                  P                  4        T P                  P                  '       d   T P                  P                  4        R# R#   \         d   p\        T4       \	        T P                   P
                  TR 7      T n         TP                  '       d   T P                  P                  4         Rp?T P                  P                  '       d   T P                  P                  4        R# R# Rp?ii ; i  \(         d    T P                  4         ELi ; i  T P                  P                  '       d   T P                  P                  4        i i ; i)r)   N)
reset_poolinterrupt_connections)r   _check_serverr
   r*   r   r   is_server_type_knownrP   
skip_sleepr   r   rS   rU   	on_changer   
isinstancer	   r   topology_versionr   ReferenceError)rW   prev_sdexcs   &  r"   rB   Monitor._run   s   '	*..G+/+=+=+?( NN$$((3399&01I1I1O1OQ_&` %  |||((===,,==='')))+''---'2N2N2N))+
 ~~&&&!!'') 'E ' 
#+<,,44C,( /// NN--/0 ~~&&&!!'') 'E
<  	JJL	 ~~&&&!!'') 'sf   H& E8 BH& 0H& AH& H& $H& 8H#AH H& H##H& &II II 9Jc                   V ^8  d   QhRR/# r   r   r   r    )r!   s   "r"   r#   r|      s     %; %;0 %;r$   c                   RV n         \        P                  ! 4       p V P                  4       #   \         d    h \
         Ed   p\        T4       T P                  pTP                  p\        T4      p\        T P                  ;'       d!    TP                  ;'       d    TP                  4      pT P                  '       d-   T P                  f   Q hT P                  P!                  YEY&4       \"        P$                  ! \&        P(                  4      '       dZ   \+        \"        \,        P.                  T P0                  P2                  T^ ,          T^,          TTR,          TT P                   R7	       T P5                  4        \7        T\8        4      '       d   h T P:                  P=                  4        \?        YBR7      u Rp?# Rp?ii ; i)zNCall hello or read the next streaming response.

Returns a ServerDescription.
N  )message
topologyId
serverHost
serverPortawaited
durationMSfailuredriverConnectionIdr)   ) r   r0   r1   _check_oncer   r   r*   r   r   r2   r?   r   r   r   r   r   publish_server_heartbeat_failedr   isEnabledForloggingDEBUGr   r   HEARTBEAT_FAILrU   _topology_idr   r   r
   r   r   r   )rW   r,   r   sdr   durationr   s   &      r"   r   Monitor._check_server   sX   
  	;##%% 	 	;e))BjjG*51H4<<[[B,C,C[[H[H[\G}}}222??SXb((77 .==#~~::&qz&qz#'$!'+}}
 ""$%!455##%$W::5	;s6   . GGAG"GAGB%G=GGc                   V ^8  d   QhRR/# r   r    )r!   s   "r"   r#   r|   #  s     ; ;. ;r$   c                X   V P                   P                  pV P                   p\        V P                  P                  ;'       d5    V P
                  ;'       d!    VP                  ;'       d    VP                  4      pV P                  '       d,   V P                  f   Q hV P                  P                  W4       V P                  '       d-   V P                  P                  '       d   V P                  4        V P                  P                  4       ;_uu_ 4       p\        P                   ! \"        P$                  4      '       d\   \'        \        \(        P*                  V P,                  P.                  VP0                  VP2                  V^ ,          V^,          VR7       VP4                  V n        VP0                  V n        V P9                  V4      w  rVVP:                  '       g   V P<                  P?                  V4       V P<                  PA                  4       w  rx\C        WWxR7      pV P                  '       d7   V P                  f   Q hV P                  PE                  WWUP:                  4       \        P                   ! \"        P$                  4      '       do   \'        \        \(        PF                  V P,                  P.                  VP0                  VP2                  V^ ,          V^,          VVR,          VPH                  R7
       VuuRRR4       #   + '       g   i     R# ; i)zVA single attempt to call hello.

Returns a ServerDescription, or raises an exception.
N)r   r   r   serverConnectionIdr   r   r   )min_round_trip_timer   )	r   r   r   r   r   r   r   r   reply)%r   r   r?   r   connsr   r   r   r   r    publish_server_heartbeat_startedr   	cancelledr   checkoutr   r   r   r   r   r   HEARTBEAT_STARTrU   r   idserver_connection_idcancel_contextr   _check_with_socket	awaitabler   
add_samplegetr   "publish_server_heartbeat_succeededHEARTBEAT_SUCCESSdocument)	rW   r   r   r   connresponseround_trip_timeavg_rttmin_rtts	   &        r"   r   Monitor._check_once#  sI   
 **22%% JJaaaa"2I2IaabNaNa
 ===??...OO<<WND$8$8$B$B$B""$ZZ  ""d((77 .>>#~~::'+ww'+'@'@&qz&qz#	 $(#6#6D  GGDM(,(?(?(E%H%%%!!,,_=#00446G"7g[B}}}222BBh8J8J ((77 .@@#~~::'+ww'+'@'@&qz&qz#.5"++ Q #"""s   FLA/LL)	c                    V ^8  d   QhRRRR/# )r   r   r   r   ztuple[Hello, float]r    )r!   s   "r"   r#   r|   `  s     " "z "6I "r$   c                   \         P                  ! 4       pVP                  '       d   \        VP	                  4       RR7      pMV P
                  '       dj   VP                  '       dX   V P                  P                  '       d<   VP                  V P                  P                  V P                  P                  4      pMVP                  RR4      p\        V4      pW43# )zSReturn (Hello, round_trip_time).

Can raise ConnectionFailure or OperationFailure.
T)r   N)r0   r1   more_to_comer   _next_replyr   performed_handshaker   r   _hellor   r   r2   )rW   r   r,   r   r   s   &&   r"   r   Monitor._check_with_socket`  s    
  T--/4@HLLLT555$:R:R:c:c:c {{((9922H {{4.H&u-!!r$   )	r   r   r   r   r   r   r   r   r   )rq   rr   rs   rt   rY   r   r   rL   ri   rS   r   rB   r   r   r   ru   __classcell__r   s   @r"   rw   rw      sI    &* &*P&
`!(*T%;N;z" "r$   rw   c                  F   a  ] tR tRtR V 3R lltR R ltR R ltRtV ;t# )	
SrvMonitorix  c                    V ^8  d   QhRRRR/# )r   r6   r   r{   r   r    )r!   s   "r"   r#   SrvMonitor.__annotate__y  s     . . .>N .r$   c                `  < \         SV `  VR\        P                  VP                  4       W n        V P
                  P                  V n        \        V P
                  P                  \        4      '       g   Q hV P
                  P                  V n        \        P                  ! 4       V n        R# )zClass to poll SRV records on a background thread.

Pass a Topology and a TopologySettings.

The Topology is weakly referenced.
pymongo_srv_polling_threadN)r   rY   r   MIN_SRV_RESCAN_INTERVALr   r   _seeds	_seedlistr   fqdnr8   _fqdnr0   r1   _startup_time)rW   r6   r{   r   s   &&&r"   rY   SrvMonitor.__init__y  s     	(**11		
 +..$..--s3333..--
!^^-r$   c                   V ^8  d   QhRR/# r\   r    )r!   s   "r"   r#   r     s      d r$   c                	L   \         P                  ! 4       V P                  \        P                  ,           8  d   R # V P                  4       pV'       d/   Wn         V P                  P                  V P                  4       R # R #   \         d    T P                  4         R # i ; irJ   )r0   r1   r  r   r   _get_seedlistr  rU   on_srv_updater   rS   )rW   seedlists   & r"   rB   SrvMonitor._run  su    >>d0063Q3QQQ%%'%N,,T^^<  " 

s   %B B#"B#c                   V ^8  d   QhRR/# )r   r   zOptional[list[tuple[str, Any]]]r    )r!   s   "r"   r#   r     s      > r$   c                    \        V P                  V P                  P                  P                  V P                  P
                  4      pVP                  4       w  r#\        V4      ^ 8X  d   \        h V P                  P                  \        V\        P                  4      4       V#   \         d7   pT P                  4        \        \         R\#        T4      R7        Rp?R# Rp?ii ; i)zHPoll SRV records for a seedlist.

Returns a list of ServerDescriptions.
zSRV monitor check failed)r   r   N)r   r  r   pool_optionsconnect_timeoutsrv_service_nameget_hosts_and_min_ttllenr   rP   update_intervalr/   r   r   ro   r   r   repr)rW   resolverr
  ttlr   s   &    r"   r  SrvMonitor._get_seedlist  s    
	#

++;;//H
 %::<MH8}! " NN**3sF4R4R+STO  	
  |-GQUVYQZ[	s   A1B) )C*4+C%%C*)r  r  r   r  )	rq   rr   rs   rt   rY   rB   r  ru   r   r   s   @r"   r   r   x  s    . .& r$   r   c                  v   a  ] tR tRtR V 3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tV ;t# )r   i  c               $    V ^8  d   QhRRRRRR/# )r   r6   r   r{   r   rz   r   r    )r!   s   "r"   r#   _RttMonitor.__annotate__  s#     $ $ $>N $VZ $r$   c                   < \         SV `  VRVP                  \        P                  4       W0n        \        4       V n        \        4       V n	        \        4       V n        R# )zLMaintain round trip times for a server.

The Topology is weakly referenced.
pymongo_server_rtt_threadN)r   rY   r   r   r   r   r   _moving_averager   _moving_minr   _lock)rW   r6   r{   rz   r   s   &&&&r"   rY   _RttMonitor.__init__  sN    
 	'11))		
 
,(?!^
r$   c                   V ^8  d   QhRR/# r\   r    )r!   s   "r"   r#   r    s      t r$   c                	Z    V P                  4        V P                  P                  4        R # rJ   )rL   r   r   r_   s   &r"   rS   _RttMonitor.close  s      	

r$   c                    V ^8  d   QhRRRR/# )r   sampler-   r   r   r    )r!   s   "r"   r#   r    s     0 0 04 0r$   c                    V P                   ;_uu_ 4        V P                  P                  V4       V P                  P                  V4       RRR4       R#   + '       g   i     R# ; i)zAdd a RTT sample.N)r  r  r   r  )rW   r%  s   &&r"   r   _RttMonitor.add_sample  s?    ZZZ  ++F3''/ ZZZs   7AA'	c                   V ^8  d   QhRR/# )r   r   ztuple[Optional[float], float]r    )r!   s   "r"   r#   r    s     F F2 Fr$   c                    V P                   ;_uu_ 4        V P                  P                  4       V P                  P                  4       3uuRRR4       #   + '       g   i     R# ; i)zBGet the calculated average, or None if no samples yet and the min.N)r  r  r   r  r_   s   &r"   r   _RttMonitor.get  s=    ZZZ''++-t/?/?/C/C/EE ZZZs   4AA%	c                   V ^8  d   QhRR/# r\   r    )r!   s   "r"   r#   r    s     % %t %r$   c                    V P                   ;_uu_ 4        V P                  P                  4        V P                  P                  4        RRR4       R#   + '       g   i     R# ; i)zReset the average RTT.N)r  r  r   r  r_   s   &r"   r   _RttMonitor.reset  s;    ZZZ  &&(""$ ZZZs   5AA%	c                   V ^8  d   QhRR/# r\   r    )r!   s   "r"   r#   r    s      d r$   c                	     V P                  4       pV P                  V4       R #   \         d    T P                  4         R # \         d    T P
                  P                  4         R # i ; irJ   )_pingr   r   rS   r   r   r   )rW   rtts   & r"   rB   _RttMonitor._run  sP    
	 **,COOC  	JJL 	JJ	s   !% A+A+A+*A+c                   V ^8  d   QhRR/# )r   r   r-   r    )r!   s   "r"   r#   r    s     . .u .r$   c                2   V P                   P                  4       ;_uu_ 4       pV P                  P                  '       d   \	        R4      h\
        P                  ! 4       pVP                  4        \        V4      uuRRR4       #   + '       g   i     R# ; i)z)Run a "hello" command and return the RTT.z_RttMonitor closedN)	r   r   rP   r   r   r0   r1   hellor2   )rW   r   r,   s   &  r"   r0  _RttMonitor._ping  s_    ZZ  ""d~~&&& 455NN$EJJL&u- #"""s   ABB	)r  r  r  r   )rq   rr   rs   rt   rY   rS   r   r   r   rB   r0  ru   r   r   s   @r"   r   r     s1    $ $"0F
%. .r$   r   c                    V ^8  d   QhRRRR/# )r   rC   r4   r   r   r    )r!   s   "r"   r#   r#     s      { t r$   c                f    \         P                  ! V \        4      p\        P	                  V4       R # rJ   )rQ   rR   _unregister	_MONITORSadd)rC   rR   s   & r"   rV   rV     s    
++g{
+CMM#r$   c                    V ^8  d   QhRRRR/# )r   monitor_refz"weakref.ReferenceType[MonitorBase]r   r   r    )r!   s   "r"   r#   r#      s     " "? "D "r$   c                0    \         P                  V 4       R # rJ   )r:  remove)r=  s   &r"   r9  r9     s    [!r$   c                   V ^8  d   QhRR/# r\   r    )r!   s   "r"   r#   r#     s      D r$   c                     \         f   R # \        \         4      p V  F$  pV! 4       pV'       g   K  VP                  4        K&  	  R pR # rJ   )r:  listrL   )monitorsrR   rC   s      r"   _shutdown_monitorsrD    sA     IH %7!!# 
 Gr$   c                   V ^8  d   QhRR/# r\   r    )r!   s   "r"   r#   r#     s      T r$   c                 ^    \         p V '       d   V ! 4        \        p V '       d
   V ! 4        R # R # rJ   )rD  r   )shutdowns    r"   _shutdown_resourcesrH    s!    !H
"H
 r$   )<__doc__
__future__r   r   atexitr   r0   rQ   typingr   r   r   pymongor   r   pymongo._csotr   pymongo.errorsr	   r
   pymongo.hellor   pymongo.lockr   pymongo.loggerr   r   r   pymongo.periodic_executorr   pymongo.pool_optionsr   pymongo.read_preferencesr   pymongo.server_descriptionr    pymongo.synchronous.srv_resolverr   pymongo.synchronous.poolr   r   r   pymongo.synchronous.settingsr   pymongo.synchronous.topologyr   _IS_SYNCr*   r2   r4   rw   r   r   setr:  rV   r9  rD  rH  registerr    r$   r"   <module>r^     s    @ "      / / - ' >  % G G 9 ) 2 8 9 
 >5.; ;|u"k u"p: :z=.+ =.F E	
"  
OO'( r$   