+\hMdZddlmZddlZddlZddlZddlZddlZddlm Z m Z m Z m Z m Z ddlmZddlmZddlmZmZmZmZddlmZmZdd lmZmZmZdd lmZdd l m!Z!m"Z"m#Z#e!e"fZ$e r dd l%m&Z&dd l'm(Z( ddl)m*Z*m+Z+m,Z,m)Z)d'dZ-dZ/dZ0dZ1ejddk(rG ddl3Z4dZ5 e4jle4jnd5Z8e5e8ddZ9e5e8ddZ:ddddZGdd Z?d,d!Z@ d-d"ZA d.d#ZBd,d$ZCd-d%ZDd/d&ZEy#e.$rd'dZ-YwxYw#e.$rddl4Z4YwxYw#1swYrxYw#e;$rdZ9dZ:YwxYw)0z)Pool utilities and shared helper methods.) annotationsN) TYPE_CHECKINGAnyNoReturnOptionalUnion)_csot) _getaddrinfo) AutoReconnectConnectionFailureNetworkTimeout_CertificateError)_get_timeout_detailsformat_timeout_details)AsyncNetworkingInterfaceNetworkingInterfacePyMongoProtocol) PoolOptions) PYSSLErrorSSLError_has_sni)_sslConn)_Address)F_GETFDF_SETFD FD_CLOEXECfcntlcTt|t}t|t|tzy)z8Set the close-on-exec flag on the given file descriptor.N)rrrr)fdflagss V/root/niggaflix-v3/playground/venv/lib/python3.12/site-packages/pymongo/pool_shared.py_set_non_inheritable_non_atomicr"4sb'" b'5:-.cy)z6Dummy function for platforms that don't provide fcntl.N)rs r!r"r"=sr#x win32cz tj||\}}t|S#ttf$r|cYSwxYwN)winreg QueryValueExintOSError ValueError)keynamedefaultvalue_s r!_queryr6KsB **35HE1u: $ N s #&::z2SYSTEM\CurrentControlSet\Services\Tcpip\Parameters KeepAliveTimeimKeepAliveIntervalctttdz}tttdz}|tks |tkr$|j t jd||fyy)Nr9)min_WINDOWS_TCP_IDLE_MS_MAX_TCP_KEEPIDLE_WINDOWS_TCP_INTERVAL_MS_MAX_TCP_KEEPINTVLioctlsocketSIO_KEEPALIVE_VALS)sockidle_ms interval_mss r!_set_keepalive_timesrGasZ*,=,DE24F4MN ) )[;S-S JJv001g{2K L.Tr#ctt|rYtt|} |jtj|}||kDr"|j tj||yyy#t $rYywxYwr+)hasattrrBgetattr getsockopt IPPROTO_TCP setsockoptr/)rD tcp_option max_valuesockoptr3s r!_set_tcp_optionrQisq 6: &fj1G //&*<*r@_MAX_TCP_KEEPCNTrDs r!rGrGvs)n.?@o/ABm-=>r#c|\}}| d|||fz}n|d|}|r||z}d|vr|t|z }t|tjr t ||t|t rdt |vr t ||t||)z9Convert a socket.error to ConnectionFailure and raise it.z %s:%d: %sz: zconfigured timeouts timed out)r isinstancerBtimeoutr SSLErrorsstrr )addresserror msg_prefixtimeout_detailshostportmsgs r!_raise_connection_failurere|sJD$ T4//b 3C' %o66%(S!u, E9 %+U*C S!u,C e+r#c.eZdZddZddZeddZy)_CancellationContextcd|_y)NF _cancelledselfs r!__init__z_CancellationContext.__init__s r#cd|_y)zCancel this context.TNrirks r!cancelz_CancellationContext.cancels r#c|jS)zWas cancel called?rirks r! cancelledz_CancellationContext.cancelledsr#N)returnNone)rrbool)__name__ __module__ __qualname__rmropropertyrqr%r#r!rgrgs  r#rgc rK|\}}|jdrttds tdtjtj}t |j  |jdtjj||d{|Stj}tjr|dk7rtj}d}t!|||tj"d{D]Z}|\}} } } } tj|| t%tdd z| }t |j  |j'tj(tj*d t-j.} | |j0} n| d krtj2d |j'tj4tj6d t9||jdtj:tjj|| | d{|j=| |cS||td7#t$r|jwxYw7#t$rtj|| | }Y~wxYw7t#tj>$r7}|jtj2d }||_ Yd}~d}~wt$r}|j|}Yd}~#d}~wwxYww)Given (host, port) and PoolOptions, connect and return a raw socket object. Can raise socket.error. This is a modified version of create_connection from CPython >= 2.7. .sockAF_UNIX-UNIX-sockets are not supported on this systemFN localhostfamilytype SOCK_CLOEXECrr;rYTr[getaddrinfo failed)!endswithrIrBr r|r"fileno setblockingasyncioget_running_loop sock_connectr/closeAF_INEThas_ipv6 AF_UNSPECr SOCK_STREAMrJrMrL TCP_NODELAYr remainingconnect_timeoutr[ SOL_SOCKET SO_KEEPALIVErGwait_for settimeout TimeoutError __cause__r^optionsrbrcrDrerrresafsocktypeprotodummysar[es r!_async_create_connectionrsJD$ }}Wvy)#$ST T}}V^^,' 6    U #**,99$E E EK^^F 4;.!! C!$V&BTBTUU$),&HeUB 6==XPQ0R%RTYZD ( 6  OOF..0B0BA Foo'G!11Ann[11 OOF--v/B/BD I  &   U #""((*77bA7   OOG $K;$L  *++w F  JJL  V 6==Xu5D 6$  ##  JJL..-CCMM  JJLC sA.L718I<)I9*I</AL7JL7)JL7C3KKK&L79I<<JL7 K=L7KL7KL4,L L7 L4L/)L7/L44L7cKt||d{}|j}||j|j|S|d} t drOt j }|jdtj|j||d{}n9t j }|jd|j|d{}|j"r>|j$s2|j&s& t)j*j-|j|j|S7077p#t$r|jtgt$r4}|jt|}t!||d|Yd}~d}~wwxYw#t$rjwxYww)Given (host, port) and PoolOptions, return a raw configured socket. Can raise socket.error, ConnectionFailure, or _CertificateError. Sets socket's SSL and timeout options. NrFserver_hostnameSSL handshake failed: rahostname)r _ssl_contextrsocket_timeoutrrrrun_in_executor functoolspartial wrap_socketrrr/r\rre verify_modecheck_hostnametls_allow_invalid_hostnamessslmatch_hostname getpeercert) r^rrD ssl_contextrbloopssl_sockexcdetailss r!_async_configured_socketrs*'7; ;D&&K ../ 1:Dc E?++-D!11!!+"9"94QUVH ++-D!11$ 8O8OQUVVH **33    x335 E  ../ OY < W     i c 'w/!'30HZabb c!  NN   svGE4GAE E9E EE $G%F*%GE E *F'3*F"G"F''G*GGc Kt||d{}|j}|j |9tt j j fd|d{S|d} t j j fd|||d{\}}|jr?|js3|js' tj j#d | tfS777c#t$rtgt$r$}t|}t||d|Yd}~d}~wwxYw#t$rj%wxYww) zGiven (host, port) and PoolOptions, return a configured AsyncNetworkingInterface. Can raise socket.error, ConnectionFailure, or _CertificateError. Sets protocol's SSL and timeout options. NctSNrrrsr!z0_configured_protocol_interface..?s 8r#rWrctSrrrsr!rz0_configured_protocol_interface..Hs OG4r#)rDrrrrpeercertr)rrrrrrcreate_connectionrr/r\rrerrrrrget_extra_infoabort) r^rrDrrb transportprotocolrrr[s @r!_configured_protocol_interfacer/st*'7; ;D&&K$$G'**,>>8t?   1:Dc%,$<$<$>$P$P 4  %Q%   8" **33    y77 Cd S $Y$9 ::U <      i c'w/!'30HZabb c!  OO   svE#C>AE#"D# E#1-DDD&$E# &E1E#E#DED=8E#=EE#E  E#c |\}}|jdrkttds tdtjtj}t |j  |j||Stj}tjr|dk7rtj}d}tj|||tjD]}|\}} } } } tj|| ttddz| }t |j  |j!tj"tj$d t'j(} | |j*} n| dkrtj,d |j/| |j!tj0tj2d t5||j| |cS||td #t$r|jwxYw#t$rtj|| | }Y7wxYw#t$r}|}|jYd}~d}~wwxYw) rzr{r|r}r~Nrrrr;rYTr)rrIrBr r|r"rconnectr/rrrr getaddrinforrJrMrLrr rrr[rrrrGrs r!_create_connectionresJD$ }}Wvy)#$ST T}}V^^,' 6  LL K^^F 4;.!! C!!$V&BTBTU),&HeUB 6==XPQ0R%RTYZD ( 6  OOF..0B0BA Foo'G!11Ann[11 OOG $ OOF--v/B/BD I  & LL K3<  *++c  JJL  & 6==Xu5D 6& C JJLL s7/H -)H*0C I H'* I I I7I22I7ct||}|j}||j|j|S|d} t dr|j ||}n|j |}|jr>|js2|js& tj j#|j|j|S#t $r|jtgt$r4}|jt|}t||d|Yd}~d}~wwxYw#t $rjwxYw)rNrTrrrr)rrrrrrrrr/r\rrerrrrrrr^rrDrrbrrrs r!_configured_socketrsB gw /D&&K ../ 1:Dc D>"..tT.JH"..t4H **33    x335 E  ../ O1     i c 'w/!'30HZabb c!  NN   s#0C%D6*D3?*D..D36Ect||}|j}|&|j|jt |S|d} t dr|j ||}n|j |}|jr>|js2|js& t!j"j%|j|jt |S#t$r|jtgt$r4}|jt|}t||d|Yd}~d}~wwxYw#t$rjwxYw)zGiven (host, port) and PoolOptions, return a NetworkingInterface wrapping a configured socket. Can raise socket.error, ConnectionFailure, or _CertificateError. Sets socket's SSL and timeout options. NrTrrrr)rrrrrrrrrr/r\rrerrrrrrrs r!_configured_socket_interfacersN gw /D&&K ../"4(( 1:Dc D>"..tT.JH"..t4H **33    x335 E  ../ x ((1     i c 'w/!'30HZabb c!  NN   s$0C'%E'*E*EEE#)rr.rrrs)rD socket.socketrNr]rOr.rrrs)rDrrrrs)NN) r^rr_ Exceptionr`z Optional[str]razOptional[dict[str, float]]rrr)r^rrrrrr)r^rrrrrzUnion[socket.socket, _sslConn])r^rrrrrr)r^rrrrrr)F__doc__ __future__rrrrBrsystypingrrrrrpymongor pymongo.asynchronous.helpersr pymongo.errorsr r r rpymongo.helpers_sharedrrpymongo.network_layerrrrpymongo.pool_optionsrpymongo.ssl_supportrrrr\pymongo.pyopenssl_contextrpymongo.typingsrrrrrr" ImportErrorr>r@rVplatform_winregr,r6OpenKeyHKEY_LOCAL_MACHINEr1r=r?r/rGrQrergrrrrrrr%r#r!rs0" 5 P``,>>  " 2( E99/<<7  ( V^^  % %'\  N #)##H '-c3F'M $  NM ?!%26 , , ,,0 ,  ,:  M,`5 5 +5#5p3; 3; +3;3;lD,N.b.)I EE E  N N ( '#' (sN8D+D:&EE E+ D76D7: EE EE E! E!