
    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)zBSynchronous cursor base extending the shared agnostic cursor base.    )annotations)abstractmethod)TYPE_CHECKINGAnyOptional)_csot)_AgnosticCursorBase)_create_lock)_DocumentType)ClientSession)
ConnectionTc                  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      V/home/ubuntu/wiki/venv/lib/python3.13/site-packages/pymongo/synchronous/cursor_base.py__init___ConnectionManager.__init__$   s    *.	(!^
    c                    Xl         g r   )r   )r   r   s     r   update_exhaust!_ConnectionManager.update_exhaust)   s    (r   c                j    U R                   (       a"  U R                   R                  5         SU l         gg)z9Return this instance's connection to the connection pool.N)r   unpinr   s    r   close_ConnectionManager.close,   s#    99IIOODI r   )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)_CursorBase3   zSynchronous cursor base class.c                t    U R                   (       a'  U R                   R                  (       d  U R                   $ g)z]The cursor's :class:`~pymongo.client_session.ClientSession`, or None.

.. versionadded:: 3.6
N)_session	_implicitr    s    r   session_CursorBase.session6   s$     ==!8!8== r   Nc                    g r   r-   )r   resulttotals      r   _next_batch_CursorBase._next_batch@   s    r   c                    U R                   nU R                  U5      u  p#U R                  R                  R
                  R                  UUU R                  U R                  5        U R                  (       a3  U R                  R                  (       a  SU R                  l
        SU l        SU l        g! [         a     gf = 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_CursorBase._die_lockD   s    	!\\N
 "11.A	!!((==NNMM		
 ==T]]4405DMM- DM  		s   B3 3
C ?C c                $    U R                  5         g)z$Explicitly close / kill this cursor.N)rH   r    s    r   r!   _CursorBase.closeX   s    r   c                $    U R                  5         g r   )r!   )r   exc_typeexc_valexc_tbs       r   __exit___CursorBase.__exit__\   s    

r   c                   / nUn[        U[        5      (       a  US:  a  [        S5      eU R                  (       aF  U R	                  X#5      (       d   U$ Ub  U[        U5      -
  nUS:X  a   U$ U R                  (       a  MF  U$ )a3  Converts the contents of this cursor to a list more efficiently than ``[doc for doc in cursor]``.

To use::

  >>> cursor.to_list()

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

  >>> 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 0r   )
isinstanceint
ValueErroraliver9   len)r   lengthres	remainings       r   to_list_CursorBase.to_list_   s      $&	fc""vzFGGjj##C33
 
	 !"SX-	>
 jjj 
r   )r2   rC   )r$   zOptional[ClientSession]r   )r7   listr8   Optional[int]r$   r#   r&   )rM   r   rN   r   rO   r   r$   r%   )rY   r_   r$   zlist[_DocumentType])r'   r(   r)   r*   r+   propertyr4   r   r9   rH   r!   rP   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.synchronous.client_sessionr   pymongo.synchronous.poolr   _IS_SYNCr   r/   r-   r   r   <module>rl      sO    I "  / /  5 % )@3 $G%m4 Gr   