
    i                        S r SSKJr  SSKJr  SSKJrJrJr  SSK	J
r
  SSKJr  SSKJr  SSKJr  \(       a  SS	KJr  SS
KJr  Sr " S S5      r " S S\\   5      rg)zCAsynchronous cursor base extending the shared agnostic cursor base.    )annotations)abstractmethod)TYPE_CHECKINGAnyOptional)_csot)_AgnosticCursorBase)_async_create_lock)_DocumentType)AsyncClientSession)AsyncConnectionFc                  6    \ rS rSrSrSS jrS	S jrS
S jrSrg)_ConnectionManager!   z?Used with exhaust cursors to ensure the connection is returned.c                :    Xl         X l        [        5       U l        g N)connmore_to_comer
   _lock)selfr   r   s      W/home/ubuntu/wiki/venv/lib/python3.13/site-packages/pymongo/asynchronous/cursor_base.py__init___ConnectionManager.__init__$   s    /3	(')
    c                    Xl         g r   )r   )r   r   s     r   update_exhaust!_ConnectionManager.update_exhaust)   s    (r   c                   #    U R                   (       a*  U R                   R                  5       I Sh  vN   SU l         gg N7f)z9Return this instance's connection to the connection pool.N)r   unpinr   s    r   close_ConnectionManager.close,   s/     99))//###DI #s   /A?A)r   r   r   N)r   r   r   bool)r   r#   returnNoner$   r%   )	__name__
__module____qualname____firstlineno____doc__r   r   r!   __static_attributes__ r   r   r   r   !   s    I*
)r   r   c                      \ rS rSrSr\SS j5       r\SSS jj5       rSS jr	SS jr
SS jr\R                  SSS	 jj5       rS
rg)_AsyncCursorBase3   zAsynchronous cursor base class.c                t    U R                   (       a'  U R                   R                  (       d  U R                   $ g)zoThe cursor's :class:`~pymongo.asynchronous.client_session.AsyncClientSession`, or None.

.. versionadded:: 3.6
N)_session	_implicitr    s    r   session_AsyncCursorBase.session6   s$     ==!8!8== r   Nc                   #    g 7fr   r-   )r   resulttotals      r   _next_batch_AsyncCursorBase._next_batch@   s     s   c                  #     U R                   nU R                  U5      u  p#U R                  R                  R
                  R                  UUU R                  U R                  5      I Sh  vN   U R                  (       a3  U R                  R                  (       a  SU R                  l
        SU l        SU l        g! [         a     gf = f N`7f)zCloses this cursor.NF)_killedAttributeError_prepare_to_die_collectiondatabaseclient_cleanup_cursor_lock	_sock_mgrr2   r3   _attached_to_cursor)r   already_killed	cursor_idaddresss       r   	_die_lock_AsyncCursorBase._die_lockD   s     	!\\N
 "11.A	''..CCNNMM	
 	
 	
 ==T]]4405DMM- DM  		
	
s5   CB= AC,C-AC=
C
C	C

Cc                @   #    U R                  5       I Sh  vN   g N7f)z$Explicitly close / kill this cursor.N)rH   r    s    r   r!   _AsyncCursorBase.closeX   s     nn   c                @   #    U R                  5       I S h  vN   g  N7fr   )r!   )r   exc_typeexc_valexc_tbs       r   	__aexit___AsyncCursorBase.__aexit__\   s     jjlrL   c                $  #    / nUn[        U[        5      (       a  US:  a  [        S5      eU R                  (       aN  U R	                  X#5      I Sh  vN (       d   U$ Ub  U[        U5      -
  nUS:X  a   U$ U R                  (       a  MN  U$  N;7f)aE  Converts the contents of this cursor to a list more efficiently than ``[doc async for doc in cursor]``.

To use::

  >>> await cursor.to_list()

Or, to read at most n items from the cursor::

  >>> await cursor.to_list(n)

If the cursor is empty or has no more results, an empty list will be returned.

.. versionadded:: 4.9
   z'to_list() length must be greater than 0Nr   )
isinstanceint
ValueErroraliver9   len)r   lengthres	remainings       r   to_list_AsyncCursorBase.to_list_   s       $&	fc""vzFGGjj))#999
 
	 !"SX-	>
 jjj 
 :s   ABB7BB)r2   rC   )r$   zOptional[AsyncClientSession]r   )r7   listr8   Optional[int]r$   r#   r&   )rN   r   rO   r   rP   r   r$   r%   )rZ   r`   r$   zlist[_DocumentType])r'   r(   r)   r*   r+   propertyr4   r   r9   rH   r!   rQ   r   applyr]   r,   r-   r   r   r/   r/   3   sR    )   ( [[ r   r/   N)r+   
__future__r   abcr   typingr   r   r   pymongor   pymongo.cursor_sharedr	   pymongo.lockr
   pymongo.typingsr   #pymongo.asynchronous.client_sessionr   pymongo.asynchronous.poolr   _IS_SYNCr   r/   r-   r   r   <module>rm      sO    J "  / /  5 + )F9 $G*=9 Gr   