
    i                       S r SSKJr  SSKJrJr  SSKJrJrJ	r	J
r
JrJrJr  SSKJr  SSKJrJr   " S S\\   \5      r\" / S	Q5      rS
SSSSSSS.r " S S5      r\\\\\\\\\\	\\4   4   4   4      \	\\4   4   r\\\4   rg)z5Constants and types shared across all cursor classes.    )annotations)ABCabstractmethod)AnyGenericMappingOptionalSequenceTupleUnion)_CursorAddress)_Address_DocumentTypec                      \ rS rSr% SrS\S'   S\S'   S\S'   S\S	'   S\S
'   S\S'   S\S'   \SS j5       rSS jr\	SS j5       r
\	SS j5       r\	SS j5       rSS jrSS jrSrg)_AgnosticCursorBase   z
Shared IO-agnostic cursor base used by both async and sync cursor classes.
All IO-specific behavior is implemented in subclasses.
r   _collectionOptional[int]_id_dataOptional[_Address]_address	_sock_mgrzOptional[Any]_sessionbool_killedc                    g)z<Return the full namespace (dbname.collname) for this cursor.N selfs    L/home/ubuntu/wiki/venv/lib/python3.13/site-packages/pymongo/cursor_shared.py_get_namespace"_AgnosticCursorBase._get_namespace)   s     	    c                $    U R                  5         g )N)_die_no_lockr   s    r!   __del___AgnosticCursorBase.__del__.   s    r$   c                n    [        [        U R                  5      =(       d    U R                  (       + 5      $ )a  Does this cursor have the potential to return more data?

This is mostly useful with `tailable cursors
<https://www.mongodb.com/docs/manual/core/tailable-cursors/>`_
since they will stop iterating even though they *may* return more
results in the future.

With regular cursors, simply use an asynchronous for loop instead of :attr:`alive`::

    async for doc in collection.find():
        print(doc)

.. note:: Even if :attr:`alive` is True, :meth:`next` can raise
  :exc:`StopIteration`. :attr:`alive` can also be True while iterating
  a cursor from a failed server. In this case :attr:`alive` will
  return False after :meth:`next` fails to retrieve the next batch
  of results from the server.
)r   lenr   r   r   s    r!   alive_AgnosticCursorBase.alive1   s#    ( C

O9DLL(8::r$   c                    U R                   $ )z5Returns the id of the cursor.

.. versionadded:: 2.2
)r   r   s    r!   	cursor_id_AgnosticCursorBase.cursor_idG   s     xxr$   c                    U R                   $ )zbThe (host, port) of the server used, or None.

.. versionchanged:: 3.0
   Renamed from "conn_id".
)r   r   s    r!   address_AgnosticCursorBase.addressO   s     }}r$   c                    SU l         U R                  (       aI  U(       dB  U R                  nU R                  c   e[        U R                  U R	                  5       5      nX#4$ SnS nX#4$ )NTr   )r   r   r   r   r"   r    already_killedr.   r1   s       r!   _prepare_to_die#_AgnosticCursorBase._prepare_to_dieX   sd    88NI==,,,$T]]D4G4G4IJG
 !! IG!!r$   c                    U R                   nU R                  U5      u  p#U R                  R                  R
                  R                  X#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 without acquiring a lock.NF)r   AttributeErrorr6   r   databaseclient_cleanup_cursor_no_lockr   r   	_implicit_attached_to_cursorr4   s       r!   r&    _AgnosticCursorBase._die_no_lockd   s    	!\\N
 "11.A	!!((@@	
 ==T]]4405DMM- DM  		s   B2 2
B?>B?)r   r   r   N)returnstr)r@   None)r@   r   )r@   r   )r@   r   )r5   r   r@   z$tuple[int, Optional[_CursorAddress]])__name__
__module____qualname____firstlineno____doc____annotations__r   r"   r'   propertyr+   r.   r1   r6   r&   __static_attributes__r   r$   r!   r   r      s     	J  NM  ; ;*    
"r$   r   )+         io  iC  `                      @      )tailable_cursorsecondary_okayoplog_replay
no_timeout
await_dataexhaustpartialc                  B    \ rS rSrSr \S   r \\S   -  r \S   rSr	g)
CursorType   r   rW   r[   r\   r   N)
rC   rD   rE   rF   NON_TAILABLE_QUERY_OPTIONSTAILABLETAILABLE_AWAITEXHAUSTrJ   r   r$   r!   r_   r_      sA    L#/0H | <<N Y'Gr$   r_   N)rG   
__future__r   abcr   r   typingr   r   r   r	   r
   r   r   pymongo.messager   pymongo.typingsr   r   r   	frozenset_CURSOR_CLOSED_ERRORSrb   r_   rA   int_Sort_Hintr   r$   r!   <module>rp      s     < " # J J J * 3Y'-0# Y| " :  : 	U3c5c7383D)D#EEFFGH'RUWZRZJ[[	 	c5jr$   