+\hUdZddlmZddlZddlZddlZddlmZddl m Z m Z m Z m Z mZmZmZmZmZmZmZddlmZddlmZddlmZdd lmZdd lmZdd lmZm Z m!Z!m"Z"m#Z#m$Z$dd l%m&Z&dd l'm(Z(ddl)m*Z*ddl+m,Z,m-Z-ddl.m/Z/ddl0m1Z1e rddl2m3Z3ddl4m5Z5ddl6m7Z7ddl8m9Z9m:Z:dZ;GddZ<GddZ= d4dZ>GddZ?GddZ@Gd d!ZAd5d"ZBd6d#ZCe&eDd$d%gzZEd&eFd'<d(ZGd7d)ZHed*ZIe rdd+lJmKZKGd,d-ZLGd.d/ZMGd0d1ZNGd2d3ejZPy)8ayLogical sessions for ordering sequential operations. .. versionadded:: 3.6 Causally Consistent Reads ========================= .. code-block:: python async with client.start_session(causal_consistency=True) as session: collection = client.db.collection await collection.update_one({"_id": 1}, {"$set": {"x": 10}}, session=session) secondary_c = collection.with_options(read_preference=ReadPreference.SECONDARY) # A secondary read waits for replication of the write. await secondary_c.find_one({"_id": 1}, session=session) If `causal_consistency` is True (the default), read operations that use the session are causally after previous read and write operations. Using a causally consistent session, an application can read its own writes and is guaranteed monotonic reads, even when reading from replica set secondaries. .. seealso:: The MongoDB documentation on `causal-consistency `_. .. _async-transactions-ref: Transactions ============ .. versionadded:: 3.7 MongoDB 4.0 adds support for transactions on replica set primaries. A transaction is associated with a :class:`AsyncClientSession`. To start a transaction on a session, use :meth:`AsyncClientSession.start_transaction` in a with-statement. Then, execute an operation within the transaction by passing the session to the operation: .. code-block:: python orders = client.db.orders inventory = client.db.inventory async with client.start_session() as session: async with await session.start_transaction(): await orders.insert_one({"sku": "abc123", "qty": 100}, session=session) await inventory.update_one( {"sku": "abc123", "qty": {"$gte": 100}}, {"$inc": {"qty": -100}}, session=session, ) Upon normal completion of ``async with await session.start_transaction()`` block, the transaction automatically calls :meth:`AsyncClientSession.commit_transaction`. If the block exits with an exception, the transaction automatically calls :meth:`AsyncClientSession.abort_transaction`. In general, multi-document transactions only support read/write (CRUD) operations on existing collections. However, MongoDB 4.4 adds support for creating collections and indexes with some limitations, including an insert operation that would result in the creation of a new collection. For a complete description of all the supported and unsupported operations see the `MongoDB server's documentation for transactions `_. A session may only have a single active transaction at a time, multiple transactions on the same session can be executed in sequence. Sharded Transactions ^^^^^^^^^^^^^^^^^^^^ .. versionadded:: 3.9 PyMongo 3.9 adds support for transactions on sharded clusters running MongoDB >=4.2. Sharded transactions have the same API as replica set transactions. When running a transaction against a sharded cluster, the session is pinned to the mongos server selected for the first operation in the transaction. All subsequent operations that are part of the same transaction are routed to the same mongos server. When the transaction is completed, by running either commitTransaction or abortTransaction, the session is unpinned. .. seealso:: The MongoDB documentation on `transactions `_. .. _async-snapshot-reads-ref: Snapshot Reads ============== .. versionadded:: 3.12 MongoDB 5.0 adds support for snapshot reads. Snapshot reads are requested by passing the ``snapshot`` option to :meth:`~pymongo.asynchronous.mongo_client.AsyncMongoClient.start_session`. If ``snapshot`` is True, all read operations that use this session read data from the same snapshot timestamp. The server chooses the latest majority-committed snapshot timestamp when executing the first read operation using the session. Subsequent reads on this session read from the same snapshot timestamp. Snapshot reads are also supported when reading from replica set secondaries. .. code-block:: python # Each read using this session reads data from the same point in time. async with client.start_session(snapshot=True) as session: order = await orders.find_one({"sku": "abc123"}, session=session) inventory = await inventory.find_one({"sku": "abc123"}, session=session) Snapshot Reads Limitations ^^^^^^^^^^^^^^^^^^^^^^^^^^ Snapshot reads sessions are incompatible with ``causal_consistency=True``. Only the following read operations are supported in a snapshot reads session: - :meth:`~pymongo.asynchronous.collection.AsyncCollection.find` - :meth:`~pymongo.asynchronous.collection.AsyncCollection.find_one` - :meth:`~pymongo.asynchronous.collection.AsyncCollection.aggregate` - :meth:`~pymongo.asynchronous.collection.AsyncCollection.count_documents` - :meth:`~pymongo.asynchronous.collection.AsyncCollection.distinct` (on unsharded collections) Classes ======= ) annotationsN)Mapping) TYPE_CHECKINGAnyAsyncContextManagerCallable CoroutinerMutableMappingNoReturnOptionalTypeTypeVar)Binary)Int64) Timestamp)_csot)_ConnectionManager)ConfigurationErrorConnectionFailureInvalidOperationOperationFailure PyMongoError WTimeoutError)_RETRYABLE_ERROR_CODES)_Op) ReadConcern)ReadPreference _ServerMode) SERVER_TYPE) WriteConcern) TracebackType)AsyncConnection)Server) ClusterTime_AddressFcdeZdZdZ d ddZed dZed dZed dZy) SessionOptionsayOptions for a new :class:`AsyncClientSession`. :param causal_consistency: If True, read operations are causally ordered within the session. Defaults to True when the ``snapshot`` option is ``False``. :param default_transaction_options: The default TransactionOptions to use for transactions started on this session. :param snapshot: If True, then all reads performed using this session will read from the same snapshot. This option is incompatible with ``causal_consistency=True``. Defaults to ``False``. .. versionchanged:: 3.12 Added the ``snapshot`` parameter. Nc|r|r tdd}n|d}||_|*t|tst dj |||_||_y)Nz5snapshot reads do not support causal_consistency=TrueFTzgdefault_transaction_options must be an instance of pymongo.client_session.TransactionOptions, not: {!r})r_causal_consistency isinstanceTransactionOptions TypeErrorformat_default_transaction_options _snapshot)selfcausal_consistencydefault_transaction_optionssnapshots f/root/niggaflix-v3/playground/venv/lib/python3.12/site-packages/pymongo/asynchronous/client_session.py__init__zSessionOptions.__init__su !()`aa!&   '!% #5 & 29;MNKKQ63L -H)!c|jS)z)Whether causal consistency is configured.)r)r0s r4r1z!SessionOptions.causal_consistencys'''r6c|jS)zThe default TransactionOptions to use for transactions started on this session. .. versionadded:: 3.7 )r.r8s r4r2z*SessionOptions.default_transaction_optionss000r6c|jS)zOWhether snapshot reads are configured. .. versionadded:: 3.12 )r/r8s r4r3zSessionOptions.snapshots ~~r6)NNF)r1Optional[bool]r2Optional[TransactionOptions]r3r;returnNoner=bool)r=r<)r=r;) __name__ __module__ __qualname____doc__r5propertyr1r2r3r6r4r'r'sz ".2DH#( "*"&B"! "  "0((11r6r'c|eZdZdZ d d dZed dZed dZed dZed dZ y)r+aOptions for :meth:`AsyncClientSession.start_transaction`. :param read_concern: The :class:`~pymongo.read_concern.ReadConcern` to use for this transaction. If ``None`` (the default) the :attr:`read_preference` of the :class:`AsyncMongoClient` is used. :param write_concern: The :class:`~pymongo.write_concern.WriteConcern` to use for this transaction. If ``None`` (the default) the :attr:`read_preference` of the :class:`AsyncMongoClient` is used. :param read_preference: The read preference to use. If ``None`` (the default) the :attr:`read_preference` of this :class:`AsyncMongoClient` is used. See :mod:`~pymongo.read_preferences` for options. Transactions which read must use :attr:`~pymongo.read_preferences.ReadPreference.PRIMARY`. :param max_commit_time_ms: The maximum amount of time to allow a single commitTransaction command to run. This option is an alias for maxTimeMS option on the commitTransaction command. If ``None`` (the default) maxTimeMS is not used. .. versionchanged:: 3.9 Added the ``max_commit_time_ms`` option. .. versionadded:: 3.7 Nc||_||_||_||_|t |t st d||8t |tst d||jstd||t |tst |d|(t |tst dt|yy)NzKread_concern must be an instance of pymongo.read_concern.ReadConcern, not: zNwrite_concern must be an instance of pymongo.write_concern.WriteConcern, not: z:transactions do not support unacknowledged write concern: zR is not valid for read_preference. See pymongo.read_preferences for valid options.z3max_commit_time_ms must be an integer or None, not ) _read_concern_write_concern_read_preference_max_commit_time_msr*rr,r acknowledgedrrinttype)r0 read_concern write_concernread_preferencemax_commit_time_mss r4r5zTransactionOptions.__init__s*+ /#5  #lK8>>J=MO  $m\:@@M?PR!--(&)+  &o{;&)*  )0#6I$OaJbIcd7 *r6c|jS)z>This transaction's :class:`~pymongo.read_concern.ReadConcern`.)rIr8s r4rPzTransactionOptions.read_concern=s!!!r6c|jS)z@This transaction's :class:`~pymongo.write_concern.WriteConcern`.)rJr8s r4rQz TransactionOptions.write_concernBs"""r6c|jS)zEThis transaction's :class:`~pymongo.read_preferences.ReadPreference`.)rKr8s r4rRz"TransactionOptions.read_preferenceGs$$$r6c|jS)zfThe maxTimeMS to use when running a commitTransaction command. .. versionadded:: 3.9 )rLr8s r4rSz%TransactionOptions.max_commit_time_msLs '''r6NNNN) rPOptional[ReadConcern]rQOptional[WriteConcern]rROptional[_ServerMode]rS Optional[int]r=r>)r=rY)r=rZr=r[)r=r\) rArBrCrDr5rErPrQrRrSrFr6r4r+r+s8/30415,0 '+'.'/ ' * '  'R""##%%((r6r+c\|r)|'|js|jrytd||S)zValidate that an explicit session is not used with an unack'ed write. Returns the session to use for the next operation. NzFExplicit sessions are incompatible with unacknowledged write concern: )rM _implicitr)sessionrQs r4_validate_session_write_concernraUsH  $]-G-G   (55B4EG Nr6c8eZdZdZddZddZ ddZy) _TransactionContextz;Internal transaction context manager for start_transaction.c||_yN)_TransactionContext__session)r0r`s r4r5z_TransactionContext.__init__ps  r6cK|SwrerFr8s r4 __aenter__z_TransactionContext.__aenter__s  cK|jjrH|#|jjd{y|jjd{yy7)7wre)rfin_transactioncommit_transactionabort_transactionr0exc_typeexc_valexc_tbs r4 __aexit__z_TransactionContext.__aexit__vsR >> ( (nn77999nn66888 )98s!6A&A""A&A$A&$A&N)r`AsyncClientSession)r=rc)rpzOptional[Type[BaseException]]rqzOptional[BaseException]rrzOptional[TracebackType]r=r>)rArBrCrDr5rhrsrFr6r4rcrcms:E! 9/ 9) 9( 9  9r6rcc$eZdZdZdZdZdZdZdZy) _TxnStateN) rArBrCNONESTARTING IN_PROGRESS COMMITTEDCOMMITTED_EMPTYABORTEDrFr6r4rvrvs DHKIOGr6rvcZeZdZdZd dZd dZd dZed dZddZ ddZ ddZ dd Z y ) _TransactionzGInternal class to hold transaction information in a AsyncClientSession.c||_tj|_d|_d|_d|_d|_d|_||_ yNFr) optsrvr}stateshardedpinned_addressconn_mgrrecovery_tokenattemptclient)r0rrs r4r5z_Transaction.__init__s@ ^^  266: "  r6cZ|jtjtjfvSre)rrvr~rr8s r4activez_Transaction.actives"zzi00)2G2GHHHr6c<|jtjk(Sre)rrvr~r8s r4startingz_Transaction.startingszzY////r6ch|jr"|jr|jjSyre)rrconnr8s r4 pinned_connz_Transaction.pinned_conns$ ;;=T]]==%% %r6cd|_|jj|_|jjt j k(r"|jt|d|_ yy)NTF) r descriptionaddressr server_typer LoadBalancerpin_txnrrr0serverrs r4pinz_Transaction.pinsT $0088    ) )[-E-E E LLN.tU;DM Fr6cKd|_|jr"|jjd{d|_y7 wre)rrcloser8s r4unpinz_Transaction.unpins7" ==--%%' ' '  (s1AA AcK|jd{tj|_d|_d|_d|_y7/wr)rrvr}rrrrr8s r4resetz_Transaction.resets;jjl^^  " sAA0Acz|jr/|jjdd|jd|_yyNr)rr_close_cursor_soonr8s r4__del__z_Transaction.__del__s1 == KK * *1dDMM B DM r6N)rr<rAsyncMongoClientr?r=zOptional[AsyncConnection]rr#rr"r=r>r=r>) rArBrCrDr5rrrErrrrrrFr6r4rrs=QI0 < !r6rc&|jd)zDRe-raise an exception with the UnknownTransactionCommitResult label.UnknownTransactionCommitResult)_add_error_labelexcs r4_reraise_with_unknown_commitrs9: r6cDt|txr|jdk(S)z/Return true if exc is a MaxTimeMSExpired error.2)r*rcoders r4_max_time_expired_errorrs c+ , ?R?r6@r frozenset_UNKNOWN_COMMIT_ERROR_CODESxc>tj|z tkS)z/Are we within the with_transaction retry limit?)time monotonic"_WITH_TRANSACTION_RETRY_TIME_LIMIT) start_times r4_within_time_limitrs >> j (+M MMr6_T)rceZdZdZ d)dZd*dZd+dZd*dZd*dZd,dZ d-dZ e d.d Z e d/d Z e d0d Ze d1d Ze d2d Ze d3dZd4dZ d5 d6dZ d5 d7dZd*dZd*dZd8dZd9dZd:dZd;dZddZe d?dZe d?dZe d?dZ e d@dZ!e dAd Z"dBd!Z#d*d"Z$dCd#Z%dDdEd$Z& dFd%Z'd*d&Z(dGd'Z)dHd(Z*y)IrtaA session for ordering sequential operations. :class:`AsyncClientSession` instances are **not thread-safe or fork-safe**. They can only be used by one thread or process at a time. A single :class:`AsyncClientSession` cannot be used to run multiple operations concurrently. Should not be initialized directly by application developers - to create a :class:`AsyncClientSession`, call :meth:`~pymongo.asynchronous.mongo_client.AsyncMongoClient.start_session`. c||_||_||_d|_d|_d|_||_td||_yre) _client_server_session_options _cluster_time_operation_time_snapshot_timer_r _transaction)r0rserver_sessionoptionsimplicits r4r5zAsyncClientSession.__init__sH*0 - :>48"!(v6r6cDK|jdd{y7w)zFinish this session. If a transaction has started, abort it. It is an error to use the session after the session has ended. TlockN _end_sessionr8s r4 end_sessionzAsyncClientSession.end_sessions T***   cbK|jj |jr|jd{|jd{|jj |jd|_yy7J74#|jj |jd|_wxYwwre)rrlrn_unpinr_return_server_session)r0rs r4rzAsyncClientSession._end_session s    + ,&&00222kkm## 33D4H4HI'+$ ,3$ 33D4H4HI'+$s> B/A>A:A>A<A> .B/:A><A>>.B,,B/cv|j-|jj|jd|_yyre)rrrr8s r4_end_implicit_sessionz(AsyncClientSession._end_implicit_sessions3    + LL / /0D0D E#'D  ,r6c2|j tdy)NzCannot use ended session)rrr8s r4 _check_endedzAsyncClientSession._check_endeds    '"#=> > (r6cK|SwrerFr8s r4rhzAsyncClientSession.__aenter__#rirjcDK|jdd{y7w)NTrrros r4rszAsyncClientSession.__aexit__&sT***rc|jS)zpThe :class:`~pymongo.asynchronous.mongo_client.AsyncMongoClient` this session was created from. )rr8s r4rzAsyncClientSession.client)s ||r6c|jS)z:The :class:`SessionOptions` this session was created with.)rr8s r4rzAsyncClientSession.options0s}}r6c|j|j|jjj|j j S)z6A BSON document, the opaque server session identifier.)r _materializertopology_descriptionlogical_session_timeout_minutesr session_idr8s r4rzAsyncClientSession.session_id5s@  $,,;;[[\##...r6c|j|jjj|jj S)z=The current transaction id for the underlying server session.)rrrrrtransaction_idr8s r4_transaction_idz"AsyncClientSession._transaction_id<s4 $,,;;[[\##222r6c|jS)zZThe cluster time returned by the last operation executed in this session. rr8s r4 cluster_timezAsyncClientSession.cluster_timeBs !!!r6c|jS)z\The operation time returned by the last operation executed in this session. rr8s r4operation_timez!AsyncClientSession.operation_timeIs ###r6c|r|S|jj}|xr t||}|r|St|j|S)z-Return the inherited TransactionOption value.)rr2getattrr)r0namevaltxn_opts parent_vals r4_inherit_optionz"AsyncClientSession._inherit_optionPsD J<<;;9'(D"9  t{{D))r6NcKtj} |j||||d{ ||d{}|js|S |jd{|S7?70#t$r\}|jr|j d{7t |tr!|jdrt|rYd}~d}~wwxYw7r#t$rS}|jdrt|rt|sYd}~|jdrt|rYd}~n d}~wwxYw&w)anExecute a callback in a transaction. This method starts a transaction on this session, executes ``callback`` once, and then commits the transaction. For example:: async def callback(session): orders = session.client.db.orders inventory = session.client.db.inventory await orders.insert_one({"sku": "abc123", "qty": 100}, session=session) await inventory.update_one({"sku": "abc123", "qty": {"$gte": 100}}, {"$inc": {"qty": -100}}, session=session) async with client.start_session() as session: await session.with_transaction(callback) To pass arbitrary arguments to the ``callback``, wrap your callable with a ``lambda`` like this:: async def callback(session, custom_arg, custom_kwarg=None): # Transaction operations... async with client.start_session() as session: await session.with_transaction( lambda s: callback(s, "custom_arg", custom_kwarg=1)) In the event of an exception, ``with_transaction`` may retry the commit or the entire transaction, therefore ``callback`` may be invoked multiple times by a single call to ``with_transaction``. Developers should be mindful of this possibility when writing a ``callback`` that modifies application state or has any other side-effects. Note that even when the ``callback`` is invoked multiple times, ``with_transaction`` ensures that the transaction will be committed at-most-once on the server. The ``callback`` should not attempt to start new transactions, but should simply run operations meant to be contained within a transaction. The ``callback`` should also not commit the transaction; this is handled automatically by ``with_transaction``. If the ``callback`` does commit or abort the transaction without error, however, ``with_transaction`` will return without taking further action. :class:`AsyncClientSession` instances are **not thread-safe or fork-safe**. Consequently, the ``callback`` must not attempt to execute multiple operations concurrently. When ``callback`` raises an exception, ``with_transaction`` automatically aborts the current transaction. When ``callback`` or :meth:`~AsyncClientSession.commit_transaction` raises an exception that includes the ``"TransientTransactionError"`` error label, ``with_transaction`` starts a new transaction and re-executes the ``callback``. The ``callback`` MUST NOT silently handle command errors without allowing such errors to propagate. Command errors may abort the transaction on the server, and an attempt to commit the transaction will be rejected with a ``NoSuchTransaction`` error. For more information see the `transactions specification`_. When :meth:`~AsyncClientSession.commit_transaction` raises an exception with the ``"UnknownTransactionCommitResult"`` error label, ``with_transaction`` retries the commit until the result of the transaction is known. This method will cease retrying after 120 seconds has elapsed. This timeout is not configurable and any exception raised by the ``callback`` or by :meth:`AsyncClientSession.commit_transaction` after the timeout is reached will be re-raised. Applications that desire a different timeout duration should not use this method. :param callback: The callable ``callback`` to run inside a transaction. The callable must accept a single argument, this session. Note, under certain error conditions the callback may be run multiple times. :param read_concern: The :class:`~pymongo.read_concern.ReadConcern` to use for this transaction. :param write_concern: The :class:`~pymongo.write_concern.WriteConcern` to use for this transaction. :param read_preference: The read preference to use for this transaction. If ``None`` (the default) the :attr:`read_preference` of this :class:`AsyncDatabase` is used. See :mod:`~pymongo.read_preferences` for options. :return: The return value of the ``callback``. .. versionadded:: 3.9 .. _transactions specification: https://github.com/mongodb/specifications/blob/master/source/transactions-convenient-api/transactions-convenient-api.md#handling-errors-inside-the-callback NTransientTransactionErrorr) rrstart_transaction BaseExceptionrlrnr*rhas_error_labelrrmr) r0callbackrPrQrRrSrretrs r4with_transactionz#AsyncClientSession.with_transactionZs=H^^% ((m_>P   $TN*&& 11333$ U + &&00222sL1++,GH*:6 $4#++,LM.z: 7 <!**+FGL^"M5s-D>A/D> A3A1A3D>C(C)C-D>1A33 C<CB1C D>CCD>C D9&'D4 D>D4.D>3D44D99D>cHK|j|jjr td|jr td|j d|}|j d|}|j d|}|$|jj }|r |j}t|||||j_ |jjd{tj|j_|jt!|S7>w)zStart a multi-statement transaction. Takes the same arguments as :class:`TransactionOptions`. .. versionchanged:: 3.9 Added the ``max_commit_time_ms`` option. .. versionadded:: 3.7 z3Transactions are not supported in snapshot sessionszTransaction already in progressrPrQrRN)rrr3rrlrr2rSr+rrrrvr~r_start_retryable_writerc)r0rPrQrRrSrs r4rz$AsyncClientSession.start_transactions  << "#XY Y   "#DE E++NLI ,,_mL ../@/R  %<<;;D%)%<%<"!3 -:L" %%'''"+"4"4 ##%"4(( (sCD"!D "?D"cjK|j|jj}|tjur t d|tj tjfvr tj|j_y|tjur t d|tjurtj|j_ |jdd{tj|j_y7$#t$r&}|jdt|Yd}~Ld}~wt$r}t|Yd}~hd}~wt $r(}|j"t$vrt|Yd}~d}~wwxYw#tj|j_wxYww)zMCommit a multi-statement transaction. .. versionadded:: 3.7 No transaction startedNz.funcas"11$ EE EEs   NT) retryable operation)rOptional[AsyncClientSession]rr"r r@r=dict[str, Any])r_retry_internalrABORT)r0r r s`` r4rz1AsyncClientSession._finish_transaction_with_retry[sh  F2 F:I FW[ F  F \\11 $ 2    sAA A A c`K|jxjdz c_|jj}|sJ|j}|di}|dk(rz|jr#t j |j|d<|jjdkDr2|sJ|j}d|d<|jddtd i|}|jjr|jj|d<|jjj||||d d{S7w) Nrwr maxTimeMSmajoritywwtimeouti' recoveryTokenT)r`rQparse_write_concern_errorrF)rrrrQrSr get_timeoutdocument setdefaultr rradmin_command)r0rr rwccmdwc_docs r4rz&AsyncClientSession._finish_transactionjs# !!Q&!  %% t   Q . .&&5+<+<+>+F#'#:#:K   ((1, r(s !!*e4!+F+    + +#'#4#4#C#CC \\''00 #t2QU1    sD%D.'D,(D.cl|j||_y||d|jdkDr||_yyy)zInternal cluster time helper.N clusterTimerr0rs r4_advance_cluster_timez(AsyncClientSession._advance_cluster_timesG    %!-D   %M*T-?-? -NN%1"O&r6ct|tstdt|t|j dt s t d|j|y)zUpdate the cluster time for this session. :param cluster_time: The :data:`~pymongo.asynchronous.client_session.AsyncClientSession.cluster_time` from another `AsyncClientSession` instance. z>()`aa   $>>? <<  % %gt 4(,(8%..99 #'#7#7#F#FGK    ."8"88&MoM`a  &&)*<*<<*3*?*?!!'.2*+((----$$))66**//<<EEB13 .))'48#'#7#7#F#FGK $)GL !' r6cX|j|jjyre)rrrIr8s r4rz)AsyncClientSession._start_retryable_write"s   //1r6cN|jjr+|j|j|jdid<|jjrN|j dkr t d|jdi}d|d<|j|j|d<yyy)NrOafterClusterTime z+Snapshot reads require MongoDB 5.0 or laterr3levelr2)rr1rrr3max_wire_versionrr)r0rrrWs r4rRz'AsyncClientSession._update_read_concern&s << * *t/B/B/NDHDWDWCNN=" -.@ A << $$r)()VWW r2B$BwK"".&*&9&9?#/ !r6ctd)NzCA AsyncClientSession cannot be copied, create a new session instead)r,r8s r4__copy__zAsyncClientSession.__copy__1s]^^r6) rrrrrr'rr@r=r>r)rr@r=r>)r=rt)rprrqrrrrr=r>)r=r)r=r')r=Mapping[str, Any]r=r)r=zOptional[ClusterTime])r=Optional[Timestamp])rstrrrr=rrX) rz7Callable[[AsyncClientSession], Coroutine[Any, Any, _T]]rPrYrQrZrRr[rSr\r=r) rPrYrQrZrRr[rSr\r=r)r rdr=r)rr"r rdr=r)rzOptional[Mapping[str, Any]]r=r>)rrar=r>)rrcr=r>)rrr=r>)r3rar=r>r?)r=zOptional[_Address]rrr]re)rr\r=r>) rUMutableMapping[str, Any]rVr@rRrrr"r=r>)rrerr"r=r>)r=r )+rArBrCrDr5rrrrrhrsrErrrrrrrrrrmrnrrr$r)r,r.r5r7rlr:r<r>r@rrCrrXrrRr`rFr6r4rtrts] 7 77 7  7  7$+ ,( ?+ // 33 "" $$ */30415,0 PIP,P. P / P * P Ph/30415,0 &)+&).&)/ &) * &)  &)P):V 8   62 16 5 B,,**,, --,(:**)****% **  **  **X2 :_r6rtc(eZdZdZddZddZddZy)rEdirtyrHc d|_d|_y)NFrgr8s r4r5z_EmptyServerSession.__init__8s ',$r6cd|_yNTrhr8s r4 mark_dirtyz_EmptyServerSession.mark_dirty<s  r6cd|_yrk)rHr8s r4rIz&_EmptyServerSession.inc_transaction_id?s '+$r6Nr)rArBrC __slots__r5rmrIrFr6r4rErE5s2I-,r6rEc>eZdZddZddZd dZed dZddZy) _ServerSessioncdttjjdi|_t j |_d|_d|_ ||_ y)NidrzrF) ruuiduuid4bytesrrrrSrrh generation)r0rws r4r5z_ServerSession.__init__DsE (:(:A!>?(   $r6cd|_y)zMark this session as dirty. A server session is marked dirty when a command fails with a network error. Dirty sessions are later discarded from the server session pool. TNrlr8s r4rmz_ServerSession.mark_dirtyLs  r6c`|ytj|jz }||dz dzkDS)NFrw<)rrrS)r0session_timeout_minutes idle_secondss r4 timed_outz_ServerSession.timed_outTs8 " *~~'$--7 6:b@@@r6c,t|jS)zPositive 64-bit integer.)rrr8s r4rz_ServerSession.transaction_id]sT))**r6c.|xjdz c_yNrw)rr8s r4rIz!_ServerSession.inc_transaction_idbs !r6N)rwrNr)r{r\r=r@rb) rArBrCr5rmr}rErrIrFr6r4rqrqCs+%A++"r6rqcLeZdZdZdfd Zd dZd dZd dZd dZd dZ xZ S)_ServerSessionPoolzDPool of _ServerSession objects. This class is thread-safe. c2t||i|d|_yr)superr5rw)r0argskwargs __class__s r4r5z_ServerSessionPool.__init__ls $)&)r6cN|xjdz c_|jyr)rwclearr8s r4rz_ServerSessionPool.resetps 1 r6c~g} |j|jj+#t$rY|SwxYwre)appendpopr IndexError)r0idss r4pop_allz_ServerSessionPool.pop_alltsE  488:001   s )/ <<c|j| |j}|j|s|S%#t$rYnwxYwt |j Sre) _clear_stalepopleftrr}rqrwr0r{ss r4rGz%_ServerSessionPool.get_server_session}sf 12 LLN;;67    doo..s8 AAct|j|jk(r|js|j|yyyre)rwrh appendleft)r0rs r4return_server_sessionz(_ServerSessionPool.return_server_sessions4  $ $ 7@T@T OON +AU 7r6c |j}|j|s|j|y5#t$rYywxYwre)rrr}rrs r4rz_ServerSessionPool._clear_stalesK HHJ;;67 A  s7 AA)rrrrr)r=zlist[_ServerSession])r{r\r=rq)rrqr=r>)r{r\r=r>) rArBrCrDr5rrrGrr __classcell__)rs@r4rrfs& /&, r6r)r`rrQrZr=r)rrr=r )rrr=r@)rfloatr=r@)QrD __future__r collectionsrrtcollections.abcrr&typingrrrrr r r r r r bson.binaryr bson.int64rbson.timestamprpymongorpymongo.asynchronous.cursorrpymongo.errorsrrrrrrpymongo.helpers_sharedrpymongo.operationsrpymongo.read_concernrpymongo.read_preferencesrrpymongo.server_typerpymongo.write_concernr typesr!pymongo.asynchronous.poolr"pymongo.asynchronous.serverr#pymongo.typingsr$r%_IS_SYNCr'r+rarcrvrrrrr__annotations__rrr!pymongo.asynchronous.mongo_clientrrtrErqdequerrFr6r4rsPwr# /    $::",@+.#925 <<~Y(Y(x ):P!099,2!2!j @*@)  C*Y&)"N  T]BK _K _\ , , " "F:**:r6