+\hddlmZddlZddlZddlZddlZddlZddlZddlZddl Z ddl m Z m Z m Z mZmZmZmZmZmZddlmZddlmZmZddlmZddlmZddlmZdd lm Z m!Z!m"Z"m#Z#m$Z$dd l%m&Z&m'Z'm(Z(m)Z)m*Z*m+Z+m,Z,m-Z-m.Z.dd l/m0Z0m1Z1dd l2m3Z3m4Z4dd l5m6Z6m7Z7m8Z8ddl9m:Z:m;Z;mm?Z?m@Z@ddlAmBZBmCZCmDZDddlEmFZFddlGmHZHmIZImJZJmKZKddlLmMZMddlNmOZOddlPmQZQddlRmSZSe rLddlmTZTddlUmVZVddlWmXZXddlmYZYddlZm[Z[m\Z\ddl]m^Z^m_Z_m`Z`ddlambZbmcZcddldmeZeddlLmfZfdd lgmhZhmiZidd!ljmkZk dd"llmmZmmnZnmoZomlZld0d#Zpd%ZrGd&d'ZsGd(d)e-ZtGd*d+ZuGd,d-ZvGd.d/Zwy#eq$rd0d$ZpYAwxYw)1) annotationsN) TYPE_CHECKINGAnyAsyncGeneratorMappingMutableMappingNoReturnOptionalSequenceUnion)DEFAULT_CODEC_OPTIONS)_csothelpers_shared)_validate_session_write_concern)_handle_reauth)command) MAX_BSON_SIZEMAX_MESSAGE_SIZEMAX_WIRE_VERSIONMAX_WRITE_BATCH_SIZE ORDERED_TYPES) AutoReconnectConfigurationErrorDocumentTooLargeExecutionTimeoutInvalidOperationNotPrimaryErrorOperationFailure PyMongoErrorWaitQueueTimeoutError)Hello HelloCompat)_get_timeout_detailsformat_timeout_details)_async_cond_wait_async_create_condition_async_create_lock)_CONNECTION_LOGGER_ConnectionStatusMessage _debug_log _verbose_connection_error_reason)ConnectionCheckOutFailedReasonConnectionClosedReason)AsyncNetworkingInterfaceasync_receive_message async_sendall) PoolOptions) SSLErrors_CancellationContext_configured_protocol_interface_raise_connection_failure)ReadPreference)_add_to_command) SERVER_TYPE) SocketChecker) CodecOptions)ObjectId) _AuthContext)AsyncClientSession)AsyncMongoClient_MongoClientErrorHandler) SnappyContext ZlibContext ZstdContext)_OpMsg_OpReply) ReadConcern) _ServerMode)_Address _CollationIn) WriteConcern)F_GETFDF_SETFD FD_CLOEXECfcntlcTt|t}t|t|tzy)z8Set the close-on-exec flag on the given file descriptor.N)rMrJrKrL)fdflagss \/root/niggaflix-v3/playground/venv/lib/python3.12/site-packages/pymongo/asynchronous/pool.py_set_non_inheritable_non_atomicrRnsb'" b'5:-.cy)z6Dummy function for platforms that don't provide fcntl.N)rOs rQrRrRwsrSFceZdZdZ d$dZd%dZ d&dZd'dZd'dZd'dZ d(dZ d)d Z d*d Z d(d Z eej ed d d d dd d d dd d df d+dZd,dZd-dZd.dZd/dZ d0dZd1d2dZ d3dZd4dZd'dZd5dZ d6dZd7dZd'dZd8dZ d9dZ!d:dZ"d;d Z#d;d!Z$dAsyncConnectionaStore 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 tj||_||_||_||_||_d|_tj|_ d|_ d|_ t|_t|_t"|_t&|_d|_d|_d|_d|_|j2j4|_|j8|_|j:|_|j2j<|_d|_ tC|_"d|_#d|_$d|_%|jL|_'|jNjQ|_)d|_*tW|_,|j2|_d|_-d|_.d|_/d|_0d|_1d|_2|j2jf|_4d|_5|jl|_6tj|_7d|_8y)NFg)9weakrefrefpool_refconnaddressidis_sdamclosedtime monotoniclast_checkin_timeperformed_handshake is_writablermax_wire_versionr max_bson_sizermax_message_sizermax_write_batch_sizesupports_sessionshello_ok is_mongosop_msg_enabledopts_event_listeners listenersenabled_for_cmapenabled_for_logging_compression_settingscompression_settingscompression_contextr9socket_checkeroidc_token_gen_idnegotiated_mechsauth_ctxgenpool_gen get_overall generationreadyr3cancel_context more_to_come service_idserver_connection_id pinned_txn pinned_cursoractivesocket_timeout last_timeout connect_rtt _client_id creation_time _cluster_time)selfr\poolr]r^r_s rQ__init__zAsyncConnection.__init__s D)     !%!1#( !& 0* 0$8!!&# #33 $ 5 5#'#;#; $(II$C$C!Y] -:_045904  --335 4H4JII "'.237! "  II44//!^^-!rSc|||jk(ry||_|jjj|y)z?Cache last timeout to avoid duplicate calls to conn.settimeout.N)rr\get_conn settimeout)rtimeouts rQset_conn_timeoutz AsyncConnection.set_conn_timeouts3 d'' ' # %%g.rSctj}|2|js%|j|jj ytj }| |j}||z }|dkrIt|j}t|}d|dd|dd|}t|dd|dd|j|t|dz|d <|j||S) Nrz5operation would exceed time limit, remaining timeout:z.5fz <= network round trip time: 2okerrmsgcode maxTimeMS) r remainingrrrnrget_rttrr#r$rrfint) rclientcmdrrtt max_time_mstimeout_details formattedrs rQ apply_timeoutzAsyncConnection.apply_timeouts//# ?$$%%dii&>&>?mmo ;""Cm ?2499=O.?ILWUXMYuvyz}u~~AJ@KLF"FB7%%   ?";#56C  g&rSc.d|_|jrJyNT)rrrs rQpin_txnzAsyncConnection.pin_txns%%%%%rSc.d|_|jrJyr)rrrs rQ pin_cursorzAsyncConnection.pin_cursors!??""?rScK|j}|r|j|d{y|jtjd{y7-7wN)r[checkin close_connr-STALE)rrs rQunpinzAsyncConnection.unpinsH}} ,,t$ $ $//"8">">? ? ? % ?s!'AA'AAAAc|jjs"|js|jjrd|_t j diSt jdddiS)NThelloOk)rn server_apirk load_balancedrmr"CMD LEGACY_CMDrs rQ hello_cmdzAsyncConnection.hello_cmdsO 99  4==DII4K4K"&D OOQ' '**Ay$? ?rScBK|jddd{S7wr)_hellors rQhellozAsyncConnection.hellos[[t,,,,s c"K|j}|j }d}|rad|_|jj|d<|jr|jj |d<|jj rbd|d<n\|Z||d<|Jt|dz|d<d}|jjr(|j|jj|z|jj}|r|jd k(r+|jr|jd z|jz|d <d d lm}|j j#||j$}|r|j'} | | |d<nd}|rt)j*} |j-d|d|d{} |rt)j* z |_t1| |} | j2|_| j4|_| j6|_| j8|_| j:|_| j<duxr | j>|_ | j<|_| jB|_!| jDtFjHtFjJtFjLtFjNtFjPfv|_)| jDtFjTk(|_+| jDtFjXk(|_-|r8|jr,|jj]| j } | |_/d|_0| jb|_2|r| jf|_4|r(|jk| |jmr||_7|jj rR| jps tsd| jp|_8|jtjw|jp|_<| S7cw)NFTr compression loadBalancedtopologyVersionrmaxAwaitTimeMSDEFAULT.saslSupportedMechsrauthspeculativeAuthenticateadmin)publish_eventsexhaust_allowed) awaitablez`Driver attempted to initialize in load balancing mode, but the server does not support this mode)=rrdrnmetadatart compressorsrrconnect_timeoutr _credentials mechanismusernamesourcepymongo.asynchronousrr<from_credentialsr]speculate_commandrarbrrr!rerfrgrhrilogical_session_timeout_minutes is_readablerjrk server_typer8 RSPrimary RSSecondary RSArbiterRSOtherRSGhostis_repl Standalone is_standaloneMongosrlget_compression_contextrurm connection_idrsasl_supported_mechsrxparse_responsespeculate_succeededryrrr{getr})rtopology_versionheartbeat_frequencyrperforming_handshakercredsrryspeculative_authenticatestartdocrctxs rQrzAsyncConnection._hellos nn#'#;#;; '+D $ II..CM((%)%>%>%J%JM"yy&&&*N#  )%5C! "&2 22$'(;d(B$CC !Iyy((%%dii&?&?BU&UV && )+,1LL3,>,O() 1((99%NH+3+E+E+G(+75MC12H NN$ELL#eU^L__ #~~/%7D cY/ ,, % 6 6"00 % 6 6$)$>$>!  1 1 = S%BSBS ?D>c>c, ((  ! !  # #  ! !       -   #..+2H2HH**k.@.@@ D$=$=++CCEDUDUVC'*D $"$)$7$7! $)$>$>D !   # #E *++- ( 99 " "##(A$..DO"mm//@DO W`sF'P)P *I#PcK|jdd{}|j|_|j}|d}tj||j |S7LwNr)receive_messagerunpack_responser_check_command_responserf)rreply unpacked_docs response_docs rQ _next_replyzAsyncConnection._next_replyYs`**400!..--/ $Q' ..|T=R=RS 1sA&A$A A&TNFcK|j| | t| |} t|ts t |}||j s | t d|j|| r| j|| |||j|| | |r |jnd}t|xr |j }|jr|j| t||||j||| | |||j ||j"|| | |j$|j||||d{S7#t&t(f$rt*$r$}|j-|d{7Yd}~yd}~wwxYww)aExecute a command or raise an error. :param dbname: name of the database on which to run the command :param spec: a command document as a dict, SON, or mapping object :param read_preference: a read preference :param codec_options: a CodecOptions instance :param check: raise OperationFailure if there are errors :param allowable_errors: errors to ignore if `check` is True :param read_concern: The read concern for this command. :param write_concern: The write concern for this command. :param parse_write_concern_error: Whether to parse the ``writeConcernError`` field in the command response. :param collation: The collation for this command. :param session: optional AsyncClientSession instance. :param client: optional AsyncMongoClient for gossipping $clusterTime. :param retryable_write: True if this command is a retryable write. :param publish_events: Should we publish events for this command? :param user_fields: Response fields that should be decoded using the TypeDecoders from codec_options, passed to bson._decode_all_selective. Nz3Collation is unsupported for unacknowledged writes.)parse_write_concern_error collationcompression_ctx use_op_msgunacknowledged user_fieldsr write_concern)validate_sessionr isinstancerdict acknowledgedradd_server_api _apply_tosend_cluster_timerpboolrm_raise_if_not_writablerrlr]rgrurr BaseExceptionr5)rdbnamespecread_preference codec_optionscheckallowable_errors read_concernrrrsessionrretryable_writerrrrprerrors rQrzAsyncConnection.commandasyR fg.1'=I$ .:D%)C)CyGX$%Z[ [ D!    dO_d K tWf5&4DNN$ mNM4N4N0NO     ' ' 7 8   ""*C# $ 8 8..-' /+- 0!/2   8007 7 7 8sOCE5AD6/D40D63E54D66E2E-"E%#E-(E5-E22E5c,K|j)||jkDrtd||jfz t|jj|d{y7#t $r$}|j |d{7Yd}~yd}~wwxYww)z}Send 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.)rgrr0r\rr r5)rmessage max_doc_sizers rQ send_messagezAsyncConnection.send_messages    )lT=O=O.O"?BNPTPbPbAcd   8 2 2G< < < 8007 7 7 8sL6B#A$A"A$!B"A$$ B-B BB B BBcK t|||jd{S7#t$r$}|j|d{7Yd}~yd}~wwxYww)zzReceive a raw BSON message or raise ConnectionFailure. If any exception is raised, the socket is closed. N)r/rhr r5)r request_idrs rQrzAsyncConnection.receive_messagesI  8.tZAVAVWW WW 8007 7 7 8sBA%#%A% AA AA A AAcB|r|jstdddddyy)z^Raise NotPrimaryError on unacknowledged write if this socket is not writable. z not primaryri{'rN)rer)rrs rQr z&AsyncConnection._raise_if_not_writables+ $"2"2!-]\a1bc c#3>rScfK|jd|j||d{y7w)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 r)rmsgrs rQ unack_writezAsyncConnection.unack_writes, ##D)\222s '1/1cK|j|dd{|j|d{}|j|}tj||j |S7P79w)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. rN)rrcommand_responserrrf)rrrrrresults rQ write_commandzAsyncConnection.write_commandsgQ'''**:66'' 6 ..vt7L7LM (6sA-A)A-A+8A-+A-c K|r|jrd|_d|_|js1|jj}|r"ddlm}|j|||d{d|_tj|jz }|jr?|jJ|jj|j|j||j rwt#j$t&j(rSt+t"t,j.|j0|jd|jd|j|yyyy7w) zhAuthenticate to the server if needed. Can raise ConnectionFailure or OperationFailure. NFrr)reauthenticateTrrclientId serverHost serverPortdriverConnectionId durationMS)rdryr~rnrrr authenticaterarbrrqrppublish_connection_readyr]r^rrr( isEnabledForloggingDEBUGr*r) CONN_READYr)rr%rrdurations rQr,zAsyncConnection.authenticates '' $ DJzzII**E5''tN'SSSDJ~~'$*<*<,K,KGMM,Z&4??!__#||A#||A'+ww'-[' TsAE !E"C=E c<|r|j|ur tdyy)zValidate this session before use with client. Raises error if the client is not the one that created the session. z>Can only use session with the AsyncMongoClient that started itN)_clientr)rrrs rQrz AsyncConnection.validate_sessions- f,&T- rSc K|jry|jd{|r|jr?|jJ|jj |j |j ||jrtjtjr]tttj|j|j d|j d|j t!||yyyy7w)z$Close this connection with a reason.Nrrrr'r(r)r*reasonr)r` _close_connrqrppublish_connection_closedr]r^rrr(r.r/r0r*r) CONN_CLOSEDrr+)rr7s rQrzAsyncConnection.close_conn+s ;;    $$~~11188twwPVW'',>,K,KGMM,Z&4@@!__#||A#||A'+ww;FC  -['  !s!DDC!DcK|jryd|_|jj |jj d{y7#t $rYywxYww)zClose this connection.NT)r`rcancelr\close Exceptionrs rQr8zAsyncConnection._close_conn@sS ;;   ""$ ))//# # #   s:/A&AAAA&A A# A&"A##A&ctr/|jj|jjS|jj S)z?Return True if we know socket has been closed, False otherwise.)_IS_SYNCrv socket_closedr\r is_closingrs rQ conn_closedzAsyncConnection.conn_closedMs9 &&44TYY5G5GH H99'') )rSc.|r|j||yy)zAdd $clusterTime.N)_send_cluster_time)rrrrs rQrz!AsyncConnection.send_cluster_timeTs   % %gw 7 rScr|jjr!t||jjyy)zAdd server_api parameters.N)rnrr7)rrs rQrzAsyncConnection.add_server_api^s( 99   GTYY%9%9 : rSc6tj|_yrrarbrcrs rQupdate_last_checkin_timez(AsyncConnection.update_last_checkin_timecs!%!1rSc||_yr)re)rres rQupdate_is_writablez"AsyncConnection.update_is_writablefs &rScDtj|jz S)z9Seconds since this socket was last checked into its pool.rHrs rQidle_time_secondsz!AsyncConnection.idle_time_secondsis~~$"8"888rScK|jrd}ntj}|j|d{t |t t gtr.t|j}t|j||y7Pw)Nr) r~r-ERRORrrIOErrorOSErrorr2r#rnr5r])rrr7detailss rQr5z)AsyncConnection._raise_connection_failuremsk ::F+11Foof%%% egw;; <*4995G %dllE7 S  &s4B BAB c4|j|jk(Sr)r\rothers rQ__eq__zAsyncConnection.__eq__syyEJJ&&rSc||k( SrrUrUs rQ__ne__zAsyncConnection.__ne__s5=  rSc,t|jSr)hashr\rs rQ__hash__zAsyncConnection.__hash__sDIIrScdjt|j|jxrdxsdt |S)NzAsyncConnection({}){} at {}z CLOSED)formatreprr\r`r^rs rQ__repr__zAsyncConnection.__repr__s8,33 O KK %I + tH  rS) r\r.rPoolr]ztuple[str, int]r^rr_r )rOptional[float]returnNone)rr>rz"Optional[MutableMapping[str, Any]]rdrcrdre)rddict[str, Any])rdr!)rz Optional[Any]r Optional[int]rdzHello[dict[str, Any]])"r strr MutableMapping[str, Any]rrFrr:rr rz#Optional[Sequence[Union[str, int]]]rzOptional[ReadConcern]rzOptional[WriteConcern]rr rzOptional[_CollationIn]rOptional[AsyncClientSession]rOptional[AsyncMongoClient]rr rr rzOptional[Mapping[str, Any]]rr rdrg)rbytesrrrdre)rrhrdzUnion[_OpReply, _OpMsg])rr rdre)rrmrrrdre)rrrrmrr:rdrg)F)r%r rdre)rrlrrkrdre)r7z Optional[str]rdrerdr )rrjrrkrrlrdre)rrjrdre)rer rdre)rdfloat)rr rdr )rVrrdr rdr)rdri)'__name__ __module__ __qualname____doc__rrrrrrrrrrrr6PRIMARYr rrrr rr#r,rrr8rCrrrIrKrMr5rWrYr\rarUrSrQrWrW~sk9"&9"9"! 9"  9"  9"v/&-O >&#@@-S'S+S  Sj (6'='=&;@D.204*/,004-1 %#37 %#W8W8'W8% W8 $ W8  W8>W8,W8.W8$(W8*W8.W8+W8W8W8 1!W8"#W8$ %W8W8r8" 8d 3$):F $ D 0 ;W   * *8)8.8+ 8  8; 2'98'! rSrWceZdZdZy)_PoolClosedErrorzZInternal error raised when a thread tries to get a connection from a closed pool. N)rqrrrsrtrUrSrQrwrwsrSrwc4eZdZddZddZd dZd dZd dZy) _PoolGenerationcNtjt|_d|_yr) collections defaultdictr _generations _generationrs rQrz_PoolGeneration.__init__s1<1H1H1MrSc<| |jS|j|S)z,Get the generation for the given service_id.r~r}rrs rQrz_PoolGeneration.gets%  ## #  ,,rSc|jS)z"Get the Pool's overall generation.)r~rs rQr|z_PoolGeneration.get_overallsrSc|xjdz c_|)|jD]}|j|xxdz cc<y|j|xxdz cc<y)z2Increment the generation for the given service_id.rNrrs rQincz_PoolGeneration.incs\ A  "// 3 !!*-2- 3   j )Q . )rSc*||j|k7S)z?Return if the given generation for a given service_id is stale.)rrrzrs rQstalez_PoolGeneration.stalesdhhz***rSNrf)rOptional[ObjectId]rdrrp)rrrdrerzrrrrdr )rqrrrsrrr|rrrUrSrQryrys -  /+rSryceZdZdZdZdZy) PoolStaterN)rqrrrsPAUSEDREADYCLOSEDrUrSrQrrs F E FrSrceZdZ d ddZddZeddZ d ddZddZ d ddZ ddZ dd Z dd Z dd Z dd d Zej d d!d Zd"dZ d d#dZd$dZd%dZd&dZddZy)'rbNc|jrtj|_ntj|_d|_t j|_t|_ t|_ t|j|_d|_d|_d|_t%|_t)j*|_||_||_||_|j2 xr:|j0j4duxr |j0j4j6|_|j2 |_t|j|_d|_|j0j>|_|j>stAd|_t|j|_|j0jB|_"d|_#||_$|j6r\|j0j4J|j0j4jK|j.|j0jL|j8r~tOjPtRjTr[tWtNftXjZ|jH|j.d|j.dd|j0jLd|_.t|_/d|_0d|_1y)z :param address: a (hostname, port) tuple :param options: a PoolOptions instance :param is_sdam: whether to call hello for each new AsyncConnection rrNinfrr'r(r))2 pause_enabledrrstater_check_interval_secondsr{dequeconnssetactive_contextsr'lockr&_max_connecting_condactive_socketsnext_connection_idreryrzosgetpidpidr]rnr_rorqrr size_condrequests max_pool_sizeromax_connecting_max_connecting_pendingrpublish_pool_creatednon_default_optionsr(r.r/r0r*r) POOL_CREATEDoperation_count_Pool__pinned_socketsncursorsntxns)rr]optionsr_ client_ids rQrz Pool.__init__sH  "))DJ"DJ()$)4(9(9(; :=%&( $;DII$F!"#+/ #$99;     < **$6 < **;;  (,||#3 1; !YY44!!!&uD %#c} ddid{n.D])} | j;t<j>d{+|j@r| J| jC|jD|jFrktIjJtLjNrGtQtHtRj>|jT|jDd|jDdyyy|t jk7r|j@r"| J| jW|jD|||jFrjtIjJtLjNrGtQtHtRjX|jT|jDd|jDd|t4sIt7j8D cgc]!} | j;t<jZ#c} ddid{yD])} | j;t<jZd{+y7O757y#1d{7swYxYwcc} w707cc} w7c78w)Nrreturn_exceptionsTrr)rinterrupt_connections)rr'r(r) serviceId).rrr`rnrrrrrzrrrrrrrr{rrappendrr notify_allrr<ror@asynciogatherrr- POOL_CLOSEDrqpublish_pool_closedr]rrr(r.r/r0r*r)rpublish_pool_cleared POOL_CLEAREDr) rr=pauserr old_statenewpidsocketsdiscardkeepr\contextrps rQ_resetz Pool._reset3sJJ >> % %{{ % % %yy&&59P9P(, I4D4D% 4: HHLL $YY[Fxx6!!&'#'($!&*jj+2C2C2E#-8->->-@*5*;*;*= JJ*D*4t, D) * "! &--  % % 0 0 2 NN % % '$#33%GNN$%? % %DII..  nnV]^ddoo&<&H&HI^&* $ND//*@*L*LMMMN$$ ,,,--dll;'',>,K,KGMM,Z&4@@!__#||A#||A -['I,,,(($00022 #-.C3 ++0B0O0OPWP]P]0^* 8 E E!%#'<<?#'<<?", nnPWXdoo&<&B&BCX&* $HD//*@*F*FGGGHe % % % % % %R_ N@Y HsR!Q.R!Q7 R!Q1R!F.Q70 R!;Q4<6R!2&R  R!"R#,R!RE9R! &R/ R!9R:,R!&R'R!1R!4R!7R =R >R R!R!R!R!cK||_|j4d{|jD]}|j|jdddd{y7A7#1d{7swYyxYww)zXUpdates the is_writable attribute on all sockets currently in the Pool. N)rerrrK)rre_sockets rQrKzPool.update_is_writablesm'99 = =:: =**4+;+;< = = = = = = = =sDA5AA5-A  A5AA5A5 A2&A) 'A2.A5cHK|jd||d{y7w)NF)r=rrr)rrrs rQresetz Pool.resets+kkJF[   s " "cFK|jddd{y7w)NF)r=rrrs rQreset_without_pausezPool.reset_without_pauseskkUk333s !!cDK|jdd{y7w)NT)r=rrs rQr=z Pool.closeskkk%%%s   c:|jj||Sr)rzrrs rQstale_generationzPool.stale_generationsxx~~c:..rSc K|j4d{|jtjk7r dddd{ydddd{|jj Ng}|j4d{|j r|j dj|jj kDrj|j|j j|j r5|j dj|jj kDrjdddd{tsItj|Dcgc]!}|jtj#c}ddid{n.|D])}|jtjd{+ |j 4d{t#|j |j$z|jj&k\r dddd{y|j(|jj&k\r dddd{y|xj(dz c_dddd{d} |j*4d{|j,|j.k\r dddd{|rT|j*4d{|xj,dzc_|j*j1dddd{|j 4d{|xj(dzc_|j j1dddd{y|xj,dz c_d}dddd{|j3d{}d}|j4d{|j4j7|k7rd}|s@|j j9||j:j=|j>dddd{|r|jtj@d{ |rT|j*4d{|xj,dzc_|j*j1dddd{|j 4d{|xj(dzc_|j j1dddd{y |rT|j*4d{|xj,dzc_|j*j1dddd{|j 4d{|xj(dzc_|j j1dddd{77o7a#1d{7swYrxYw7L7#1d{7swYxYwcc}w7e7;7&777#1d{7swYxYw77d7P7#1d{7swY%xYw77#1d{7swYyxYw7#1d{7swYxYw777K#1d{7swY\xYw7;7&7#1d{7swYxYw77#1d{7swYyxYw77u#1d{7swYxYw7y7=#1d{7swYNxYw#|rl|j*4d{7|xj,dzc_|j*j1dddd{7n#1d{7swYnxYw|j 4d{7|xj(dzc_|j j1dddd{7w#1d{7swYwxYwxYww)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. NrTrF)!rrrrrnmax_idle_time_secondsrrMrpopr@rrrr-IDLErlenr min_pool_sizerrrrnotifyconnectrzr| appendleftrrrr)rreference_generation close_connsr\ incrementedrs rQremove_stale_socketszPool.remove_stale_socketssz99  zzY__,      99 * * 6Kyy 9 9JJ 288:TYY=\=\\&&tzz~~'78JJ 288:TYY=\=\\ 9 9 nnOZ[tdoo&<&A&AB[&* (GD//*@*E*EFFFG~~ # #tzz?T%8%88DII>,,MMQ&MNN))+,,,-MMQ&M"&K ''"\\^+" 99JJxx++-1EE%) % --d3,,44T5H5HIJJ//*@*F*FGGG#88;; * 1188:;; >>,,MMQ&MNN))+,,,#88;; * 1188:;; >>,,MMQ&MNN))+,,K+        9 9 9 9 9\ G # # # # # # #''.;;;;;,,,,,7'''',JJJJJH ;;;;;,,,,, ;;;;;,,,,, #88;; * 1188:;;;;; >>,,MMQ&MNN))+,,,,,sA_V-_V6 _V0_V3-_W _B*W/ _:W;_&W(> _W- ,_5W06_ W3_;W? _W6_$W? _ W9 _W?' _2W<3_:[< X [<Y) [<4X5[<9_ X _0X!? _ X _X7 _#0X= _X:_$Y; [<Y[<Y+[<5Y.6[<9A"Y4 [<&Y1'([<Z [<_'Z (_+0Z _&Z'_;Z)<_?0Z// _:Z,;__[_0[  _[_'[ (_+0[& _&[#'_0_3_6W <V? =W  __W%W W% _0_3_6_9_<_?XX X _[<[<__!X4'X* (X4/ _:_=YY Y _[<Y(Y Y(# [<.[<1[<4Z:Y= ;Z [< __Z&Z Z&! _,_/[5Z8 6[=__ [[ [ _#_&[9,[/ -[94_<_\ _0] _]_]( ]]( $_;]> <_0_0 _;^><__ _  _ __c  K|j4d{|j}|xjdz c_t}|jj |dddd{|j j }|jr |J|j|j|jrjtjtjrGttt j"|j$|jd|jd t'|j|j d{}tC|||j|jD}|j4d{|jj |jF|jj+dddd{jHr|jFjK |jDs)|jMd{|jN|_'|r|jQ|d|jSd{|r7|jVjXj[|j\d{|S775#1d{7swYFxYw7m#t($r}|j4d{7|jj+dddd{7n#1d{7swYnxYw|jr/|J|j-|jt.j0|jrtjtjrnttt j2|j$|jd|jdt5t.j0t.j0t7|t8t:gt<r-t?|j }tA|j||d}~wwxYw77x#1d{7swYxYw7F7 #t($r|j4d{7|jj+|jFdddd{7n#1d{7swYnxYw|jUt.j0d{7wxYw7mw) zConnect to Mongo and return a new AsyncConnection. Can raise ConnectionFailure. Note that the pool does not keep a reference to the socket -- you must call checkin() when you're done with it. Nrrrr'r(r)r*r6rOF)completed_handshake)/rrr3raddrnrorqpublish_connection_createdr]rrr(r.r/r0r*r) CONN_CREATEDrr4r rr9r-rPr:r+rrQrRr2r#r5rWr_r cancelledr<rrecontribute_socketr,rr _topologyreceive_cluster_timer) rhandlerconn_id tmp_contextrpnetworking_interfacerrSr\s rQrz Pool.connects99 2 2--G  # #q ( #.0K  $ $[ 1  2 2II..  ( ((  0 0w G  # #(:(G(G (V "0==<<?<<?#*   )G VZV_V_)`#` 63T4<<RVR^R^_99 6 6  $ $T%8%8 9  ( ( 5 6 6     & & ( <<jjl""#'#3#3 ))$E)J##% % % ..**??@R@RS S S S 2 2 2 2 2,$a yy : :$$,,[9 : : : : :$$ ,,,33LL'+A+G+G'',>,K,KGMM,Z&4@@!__#||A#||A'.;">? ? ?    TsTJTAJ! T)J*BQ)Q#=Q)Q&Q) 4TTTT!J4'J* (J4/T7J:: QP?KP?L5 P?LP?L LL D*P??QT T Q Q Q T#Q)&Q))S>RS>&R?- S>8R;9S>?S SS )S>6S97S>>Tc K|jj}tj}|jr|J|j |j |jritjtjrFtttj|j|j d|j d|j!||d{}tj|z }|jr+|J|j#|j |j$||jrutjtjrRtttj&|j|j d|j d|j$| |j(4d{|j*j-|j.dddd{||j2rV|j(4d{|j@j-||xjBdz c_!dddd{y|j4rV|j(4d{|j@j-||xjDdz c_"dddd{y|j<r|j?|d{yy77-7#1d{7swY xYw#t0$ry|j2xs |j4}|r3t7j8\}}} |j;||d{7|s&|j<r|j?|d{7wxYw7r75#1d{7swYyxYw7+7#1d{7swYyxYw7ޭw)aGet a connection from the pool. Use with a "with" statement. Returns a :class:`AsyncConnection` object wrapping a connected :class:`socket.socket`. This method should always be used in a with-statement:: with pool.get_conn() as connection: connection.send_message(msg) data = connection.receive_message(op_code, request_id) Can raise ConnectionFailure or OperationFailure. :param handler: A _MongoClientErrorHandler. Nrrrrr&)#rnrorarbrq$publish_connection_check_out_startedr]rrr(r.r/r0r*r)CHECKOUT_STARTEDr _get_connpublish_connection_checked_outr^CHECKOUT_SUCCEEDEDrrrrr rrsysexc_infohandlerrrrr) rrrpcheckout_started_timer\r2pinnedexc_typeexc_val_s rQcheckoutz Pool.checkoutAs &II.. $ 0  ( ((  : :4<< H  # #(:(G(G (V "0AA<<?<<?  ^^$97^KK>>#&;;  ( ((  4 4T\\477H U  # #(:(G(G (V "0CC<<?<<?#'77#  yy > >$$(()<)<= > >J ??yy  %%))$/ a      yy # #%%))$/ "  # # #[[,,t$ $ $WL" > > > > >  __:(:(:F(+||~$'1nnXw777dkkll4(((        # # # # # %sC!O #K2$CO 8LK5 L &K:2 L=K8> LO #N$O '1N O #N$!O N0O  1N5: O N3%O +O ,O 5L8L:L L L LAN"M%#'N N  NO O N-!N$ "N-)O 3O 5O;N> <OO c |jtjk7r:|rtj|z }|j rW|j jJ|j jj|jtj||jrztjtj rWt#tt$j&|j(|jd|jddtj|t+|j }t-|jt/d|yy)Nrr>+.CC((9955AAAII..RR &D&O&OQY++0B0O0OPWP]P]0^* 8 H H!%#'<<?#'<<?]<GG#+ +4995G % m,DEW^ + )rSc ,K|jtjk7r|jd{|jr t j |z }|jrW|jjJ|jjj|jtj||jrztj t"j$rWt'tt(j*|j,|jd|jddtj|t/d|j04d{|xj2dz c_dddd{t5j6rt5j8}nD|jj:r,t j |jj:z}nd}|j<4d{|j?|d|j@|jBks|r|t j z nd}tE|j<|d{sD|j@|jBkr|j<jG|jI||j?|d|j@|jBks|xj@dz c_ dddd{d}d }d } |j04d{|xjJdz c_%d}dddd{||jL4d{|j?|d |jNs|jP|jRks|r|t j z nd}tE|jL|d{sR|jNs|jP|jRkr|jLjGd}|jI||j?|d |jNs|jP|jRks |jNjU}dddd{|r|jY|d{rsd}^ |j[| d{}|jL4d{|xjPdzc_(|jLjGdddd{|d|_3|S777#1d{7swYxYw7<77G#1d{7swYXxYw7D7 #1d{7swY1xYw7!7#tV$r|xjPdz c_(Y,wxYw7%#1d{7swY6xYw7#777#1d{7swYxYw#|jL4d{7|xjPdzc_(|jLjGdddd{7w#1d{7swYwxYwxYw#t\$r|r(|j_t`jbd{7|j<4d{7|xj@dzc_ |r|xjJdzc_%|j<jGdddd{7n#1d{7swYnxYw|st j |z }|jrW|jjJ|jjj|jtjd||jrztj t"j$rWt'tt(j*|j,|jd|jdd tjd|wxYww) z=Get or create a AsyncConnection. Can raise ConnectionFailure.NrrzConnection pool was closedrz?Attempted to check out a connection from closed connection poolT)rFrr)4rrrrr`rarbrqrnrorr]r,rrrr(r.r/r0r*r)rrrwrrr get_timeout get_deadlinewait_queue_timeoutrrrrr%r_raise_wait_queue_timeoutrrrrrpopleft IndexError _perishedrr rr-rPrr) rrrr2deadlinerr\r emitted_events rQrzPool._get_conns 88ryy{ "**, , , ;;~~'*??H$$yy11=== **NNLL"@"L"Lh'',>,K,KGMM,Z&4DD!__#||A#||A78DD' #Q 99 & &  A %  & &    ))+H YY ) )~~'$))*F*FFHH>>    $ $%:t $ L}}t'9'999A(T^^%55t-dnngFFF}}t'9'99--/223HI(()>4(P}}t'9'99 MMQ M    @ yy # ###q(#"  # #, 44++,,-Bu,U#zzT]]T=Q=Q-QAI(T^^-="=t%5d6O6OQX%YYY $zzT]]T=Q=Q-Q $ 9 9 @ @ B,0M ::;PQ001FSX0Y $zzT]]T=Q=Q-Q+#zz113++"!^^D111# ?%)\\'\%BB#'#<#<?? MMQ.M 55<<>??9,|  o -0 & & & & & G    $ # # # # # + Z&+ * +++++$2 C?????4#<#<?? MMQ.M 55<<>????? oo&<&B&BCCC~~ ( ( " ''1,'%%'  ( ( ( ( ( !>>+.CC((9955AAAII..RR &D&O&OQY++0B0O0OPWP]P]0^* 8 H H!%#'<<?#'<<?]<GG#+  9 s5`T(D,`$T+%`(T1> ` T. B` U `A!U0U 1A4U&U; `U  `Y"U&#Y&U,> Y U) Y!V"Y%A-V0VBV0#V= YV- Y#W$Y-W%W W%YW Y0W YWY `+`.`1U7T: 8U? ` U `U#U U#`&Y)Y,U?2U5 3U?: YV0V*&V0)V**V0-Y0W6V9 7W> Y W% YYW"W W"Y%Y6W9 7Y;0X=+ Y6X97Y=Y YY YY.`Z`Z`A[7% `0[31`7\ =\>\ D ``c n K|j}|j}d|_d|_d|_|jj ||j j }|j4d{|jj |jdddd{|jr*|J|j|j|j|jrttj t"j$rQt'tt(j*|j,|jd|jd|j|j.t1j2k7r|j5d{n|j6r)|j9t:j<d{n|j6r|jr9|J|j?|j|jt:j@|jrtj t"j$r[t'tt(jB|j,|jd|jd|jtEt:j@t:j@nd}|j4d{|jG|jH|jJrd}ni|jM|jOtQ|jR|jTjW||jXj[dddd{|r'|j9t:j\d{|j^4d{|r|xj`dzc_0n|r|xjbdzc_1|xjddzc_2|xjfdzc_3|xjhdzc_4|j^j[dddd{y77#1d{7swYxYw7777#1d{7swYxYw777G#1d{7swYyxYww)zReturn the connection to the pool, or if it's closed discard it. :param conn: The connection to check into the pool. FNrrrr6T)5rrrrrrnrorrrrqpublish_connection_checked_inr]r^rrr(r.r/r0r*r) CHECKEDINrrrrrr`rr-rr9rPr:r+rr}rrIrKr rerrrrrrrrrrr)rr\txncursorrprs rQrz Pool.checkin+s oo## " %%d+II.. 99 > >  ( ()<)< = > >  ( ((  3 3DLL$'' J  # #(:(G(G (V "0::<<?<<?#'77   88ryy{ "**, , ,{{oo&<&H&HIII(($00077 dgg/E/K/K++0B0O0OPWP]P]0^* 8 D D!%#'<<?#'<<?+/77?@V@\@\]4:: # 99 ; ;,,T__dooN%) 557//T5E5E0FG --d31188: ; ;//*@*F*FGGG>> $ $ a  " MMQ M   1 $   A % NN ! ! # $ $ $k > > > > > -J* ; ; ; ; ;H $ $ $ $ $sA/R51Q2R55&Q" R5&Q'C.R5Q84R5 Q; DR5Q>R5"BR5 R5R(R5)R*R5>R?R5B R  R5RR5R5"Q5(Q+ )Q50 R5;R5>R5R5R R R R5R5R5 R2&R) 'R2.R5cFK|j}|jjA||jjkDr(|jtj d{y|j V|j dk(s||j kDr8|jr(|jtjd{y|j|j|jr(|jtjd{yy77V7 w)aReturn 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. NTrF) rMrnrrr-rrrCrPrr}rr)rr\rMs rQrzPool._perishedvs!224 II + + 7!DII$C$CC//"8"="=> > >  ' ' 3  ( (A -1BTEaEa1a!oo&<&B&BCCC  $// B//"8">">? ? ? ?D @s8A"D!$D%A!D!DA D!DD!D!D!c |jj}tj|z }|jr/|J|j |j tj||jrztjtjrWtttj |j"|j d|j ddtj|t%j&xs|jj(}|jj*rl|j,|j.z |j0z }t3dj5|jj6|j.|j0||t3d|jj6d|)NrrzBWait queue timeout elapsed without a connection becoming availablerzTimeout 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: )rnrorarbrqrr]r,TIMEOUTrrr(r.r/r0r*r)rrrr r rrrrr r_r)rrrpr2r other_opss rQr zPool._raise_wait_queue_timeoutsmII.. >>#&;;  ( ((  9 9 <DDh   # #(:(G(G (V "0@@<<?<<?[4<<# ##%E)E)E 99 " "++dmm;djjHI'78>vII++MMJJ 8  $  II334Ky J  rScVtr#|jD]}|jdyyr)r@rr)rr\s rQ__del__z Pool.__del__s+   &% & rS)FN)r]rGrr1r_r rrrfrn)TNF) r=r rr rrrr rdre)rezOptional[bool]rdre)NF)rrrr rdrer)rrrdrer)r"Optional[_MongoClientErrorHandler]rdrW)rrrdz%AsyncGenerator[AsyncConnection, None])rrorr rdre)rrorrrdrW)r\rWrdre)r\rWrdr )rrordr )rqrrrsrr~propertyr`rrKrrr=rrr contextlibasynccontextmanagerrrrrrr rrUrSrQrbrbs_ (, TTT T & Tl".. )-&+ [H[H[H' [H $ [H  [Hz=TY , LP  4&/C,JQf##<@L%9L% .L%$L%\6[_%*5W BI$V"H% N&rSrb)rOrrdre)x __future__rrr{rr/rrrarYtypingrrrrrr r r r bsonr pymongorr#pymongo.asynchronous.client_sessionrpymongo.asynchronous.helpersrpymongo.asynchronous.networkrpymongo.commonrrrrrpymongo.errorsrrrrrrrrr pymongo.hellor!r"pymongo.helpers_sharedr#r$ pymongo.lockr%r&r'pymongo.loggerr(r)r*r+pymongo.monitoringr,r-pymongo.network_layerr.r/r0pymongo.pool_optionsr1pymongo.pool_sharedr2r3r4r5pymongo.read_preferencesr6pymongo.server_apir7pymongo.server_typer8pymongo.socket_checkerr9r: bson.objectidr;pymongo.asynchronous.authr<r=!pymongo.asynchronous.mongo_clientr>r?pymongo.compression_supportr@rArBpymongo.messagerCrDpymongo.read_concernrErFpymongo.typingsrGrHpymongo.write_concernrIrMrJrKrLrR ImportErrorr@rWrwryrrbrUrSrQr?s8#    ')O70   -O  a`, 4.+0!&6F\ 10462 E99/ Y Y x| ++>@ &@ &iEE Es2E88 FF