f02VdZddlmZddlZddlmZddlmZmZmZm Z m Z m Z ddl m Z ddlmZmZddlmZmZdd lmZmZmZdd lmZmZmZmZdd lmZmZer@dd l m!Z!dd l"m#Z#ddl$m%Z%ddl&m'Z'm(Z(ddl)m*Z*ddl+m,Z,ddl-m.Z.m/Z/ddl0m1Z1ddl2m3Z3ddl4m5Z5ddddiZ6GddZ7y)z2Communicate with one MongoDB server in a topology.) annotationsN)datetime) TYPE_CHECKINGAnyCallableContextManagerOptionalUnion)_decode_all_selective)NotPrimaryErrorOperationFailure)_check_command_response_handle_reauth)_COMMAND_LOGGER_CommandStatusMessage _debug_log)_convert_exception_GetMore_OpMsg_Query)PinnedResponseResponse)Queue) ReferenceType)ObjectId) MongoClient_MongoClientErrorHandler)Monitor)_EventListeners) ConnectionPool) _ServerMode)ServerDescription) _DocumentOutcursor) firstBatch nextBatchceZdZ d ddZddZdddZddZddZe ddZ d ddZ e dd Z e jdd Z e dd Z dd Zdd Zy)ServerNc||_||_||_||_|duxr |j|_||_d|_|j r ||_yy)zRepresent one MongoDB server.N) _description_pool_monitor _topology_idenabled_for_server_publish _listener_events)selfserver_descriptionpoolmonitor topology_id listenerseventss W/var/lib/jenkins/workspace/mettalog/venv/lib/python3.12/site-packages/pymongo/server.py__init__zServer.__init__.s\/  '!-N)2N2N " ==!8DL cz|jjjs|jj yy)z[Start monitoring, or restart after a fork. Multiple calls have no effect. N)r-opts load_balancedr.openr4s r;rAz Server.openBs* zz,, MM   -r=c:|jj|y)zClear the connection pool.N)r6reset)r4 service_ids r;rDz Server.resetJs  #r=c^|jrm|jJ|jJ|jj|jj|j j |jff|jj|jjy)zXClear the connection pool and stop the monitor. Reconnect with open(). N) r1r2r3putpublish_server_closedr,addressr/r.closer-rBs r;rJz Server.closeNs ==>>- --<<+ ++ LL  NN88&&..0A0AB   r=c8|jjy)zCheck the server's state soon.N)r. request_checkrBs r;rLzServer.request_check_s ##%r=c d}|J|j}tj} |j|} |jxr|jj } | rd} n(|j ||| } |j| \} }}|j|\}}tjtjrtt|jjt j"|t%t'||| | |j(|j*|j,d|j,d|j. |rV|j|\}}d|vr||d<|J|j1||| |j,|j*|j. | r|j3d}n#|j5|j3| }| r t6}d}nd}d}|||j8|j:|| }| rA|d}|j<j?||j@tC||jDtj| z }| r|d}nY|jVd k(r |r|dni}n@|j8|jYd dd}|jVdk(r ||dd<n||dd<tjtjrtt|jjt jZ||t%t'||| | |j(|j*|j,d|j,d|j.|rE|J|j]|||jV| |j,|j*|j.| |j<}|rN|j^rB| r@|j^ja|jc}te||j:|}|jg|j@s |jhr|jktI|tlr |j } n#to|jhxr |j8} |jr|jjq| ts||jtj,||| | || }|Stw||jtj,|| | |}|S#tF$rM}tj| z }tI|tJtLfr |jN}n tQ|}tjtjrtt|jjt jR||t%t'||| | |j(|j*|j,d|j,d|j.tI|tL |rE|J|jU|||jV| |j,|j*|j.| d}~wwxYw)a Run a _Query or _GetMore operation and return a Response object. This method is used only to run _Query/_GetMore operations from cursors. Can raise ConnectionFailure, OperationFailure, etc. :param conn: A Connection instance. :param operation: A _Query or _GetMore object. :param read_preference: The read preference to use. :param listeners: Instance of _EventListeners or None. :param unpack_res: A callable that decodes the wire protocol response. Nrr&) clientIdmessagecommand commandName databaseName requestId operationIddriverConnectionIdserverConnectionId serverHost serverPort serviceIdz$db)rEFT)legacy_response user_fields)rNrO durationMSfailurerQrRrSrTrUrVrWrXrYisServerSideError)rE database_nameexplain)idns)r%okfindr%r'r() rNrOr\replyrQrRrSrTrUrVrWrXrY)datarIconnduration request_id from_commanddocs more_to_come)rfrIrhrirjrk)<enabled_for_commandsrnow use_commandconn_mgrrl get_message_split_message as_commandr isEnabledForloggingDEBUGr_topology_settingsr/rSTARTEDnextiterraserver_connection_idrIrEpublish_command_startreceive_message send_message_CURSOR_DOC_FIELDS cursor_id codec_optionsclient_process_responsesessionrmax_wire_version Exception isinstancer r detailsrFAILEDpublish_command_failurename namespace SUCCEEDEDpublish_command_success _encrypterdecryptraw_command_responser _should_pin_cursorexhaust pin_cursorrboolupdate_exhaustrr,r)r4rg operationread_preferencer9 unpack_resrrhpublishstartuse_cmdrlrirOrf max_doc_sizecmddbnrer[rZrkfirstexcr]res decryptedresponses r; run_operationzServer.run_operationcs,$$$00 ''- ))Mi.@.@.M.M J++OT7KG-1-@-@-I *Jl''-S  ' ' 6 22??-55 cO $&#'77#'#<#<<<?<<?//   ++D1HCC E ( ((  + + ))?? , = ,,T2!!$ 5,,Z80 "'" "&##'' /' DQ  225):K:KL't/D/DEL<<>E) q'C ^^y (!$q'rC$)OO9;N;N;PQYZ[C~~'.2H l+-1H k*  ' ' 6 22??-77# cO $&#'77#'#<#<<<?<<?//  ( ((  - - ))??! . !! f''"--55e6P6P6RS ,Y 8O8OQ\]  $ $Y%6%6 79;L;L OO %( %11  $I$5$5$I%//J !!""11,?%))11!%$) H( ))11!%$ Hq$ ||~-H#1ABC(+ ,S1++GMM:##66CC188'# $T#Y!$( *'+ww'+'@'@#||A#||A"oo&06F&G" ,,,11NNLL--#"%2  I$ s!B*T Y EYYc8|jj|SN)r6checkout)r4handlers r;rzServer.checkout9syy!!'**r=c|jSr)r,rBs r; descriptionzServer.description>s   r=c\|j|jjk(sJ||_yr)rIr,)r4r5s r;rzServer.descriptionBs*!))T->->-F-FFFF.r=c|jSr)r-rBs r;r6z Server.poolGs zzr=c6t|dk(r|S|\}}||dfS)zReturn request_id, data, max_doc_size. :param message: (request_id, data, max_doc_size) or (request_id, data) r)len)r4rOrirfs r;rrzServer._split_messageKs. w<1 N ' JtQ& &r=cPd|jjd|jdS)N< >) __class____name__r,rBs r;__repr__zServer.__repr__Ys)4>>**+1T->->,ACCr=)NNN)r5r#r6r!r7rr8Optional[ObjectId]r9Optional[_EventListeners]r:zOptional[ReferenceType[Queue]]returnNone)rrr)rErrr)rgr rzUnion[_Query, _GetMore]rr"r9rrz!Callable[..., list[_DocumentOut]]rrrr)rz"Optional[_MongoClientErrorHandler]rzContextManager[Connection])rr#)r5r#rr)rr!)rOz,Union[tuple[int, Any], tuple[int, Any, int]]rztuple[int, Any, int])rstr)r __module__ __qualname__r<rArDrJrLrrrpropertyrsetterr6rrrr=r;r*r*-sD +//315$-$$ $ ( $ - $/$ $(!$"&SS+S% S - S 6 SS SSl=A+9+ #+ !!// 'C '  'Dr=r*)8__doc__ __future__rrurtypingrrrrr r bsonr pymongo.errorsr r pymongo.helpersrrpymongo.loggerrrrpymongo.messagerrrrpymongo.responserrqueuerweakrefr bson.objectidrpymongo.mongo_clientrrpymongo.monitorrpymongo.monitoringr pymongo.poolr r!pymongo.read_preferencesr"pymongo.server_descriptionr#pymongo.typingsr$rr*rr=r;rsp9"PP&<CMMHH5%&J'2-4<,qq ABmDmDr=