+
    Q?j                    B    ^ RI Ht ^ RIt^ RIt^RIHt  ! R R4      tR# )    )annotationsN)WebSocketQueueFullErrorc                  r    ] tR t^	tRtRR R lltR R ltR R ltR R	 ltR
 R lt	R R lt
R R ltRtR# )	SendQueuezBounded byte-size queue for outgoing WebSocket messages.

Messages are stored as pre-serialized strings. The queue enforces a
maximum byte budget so that unbounded buffering cannot occur during
reconnection windows.
c                    V ^8  d   QhRRRR/# )   	max_bytesintreturnNone )formats   "{/home/vela/workspace/domain/tn-silver/web/tn-site/.runtime/imagegen-venv/lib/python3.14/site-packages/openai/_send_queue.py__annotate__SendQueue.__annotate__   s     & &# &d &    c                	b    . V n         ^ V n        Wn        \        P                  ! 4       V n        R# r   N)_queue_bytes
_max_bytes	threadingLock_lock)selfr	   s   &&r   __init__SendQueue.__init__   s#    -/#^^%
r   c                    V ^8  d   QhRRRR/# )r   datastrr   r   r   )r   s   "r   r   r      s     ' 'C 'D 'r   c                `   \        VP                  R4      4      pV P                  ;_uu_ 4        V P                  V,           V P                  8  d   \        R4      hV P                  P                  W34       V ;P                  V,          un        RRR4       R#   + '       g   i     R# ; i)zvAppend *data* to the queue.

Raises :class:`WebSocketQueueFullError` if the message would
exceed the byte-size limit.
zutf-8z%send queue is full, message discardedN)lenencoder   r   r   r   r   append)r   r   byte_lengths   && r   enqueueSendQueue.enqueue   sp     $++g./ZZZ{{[(4??:-.UVVKK23KK;&K	 ZZZs   A#BB-	c                    V ^8  d   QhRRRR/# )r   sendztyping.Callable[[str], object]r   r   r   )r   s   "r   r   r   $   s      = $ r   c           	     
   V P                   ;_uu_ 4        \        V P                  4      pV P                  P                  4        ^ V n        RRR4       \        X4       F  w  pw  rE V! V4       K  	  R#   + '       g   i     L2; i  \         do    T P                   ;_uu_ 4        Y#R pY`P                  ,           T n        \        R T P                   4       4      T n        RRR4       h   + '       g   i     h ; ii ; i)zSend every queued message via *send*.

If *send* raises, the failing message and all subsequent messages
are re-queued and the error is re-raised.
Nc              3  *   "   T F	  w  rVx  K  	  R # 5iNr   .0_bls   &  r   	<genexpr>'SendQueue.flush_sync.<locals>.<genexpr>6        %BkUQbk   r   listr   clearr   	enumerate	Exceptionsumr   r)   pendingir   _byte_length	remainings   &&     r   
flush_syncSendQueue.flush_sync$   s     ZZZ4;;'GKKDK 
 (1'9#A#T
 (: Z  ZZZ 'I"+kk"9DK"%%Bdkk%B"BDK   	  Z s/   7A6(B	6B		D(=C.	%	D.C>9	Dc                    V ^8  d   QhRRRR/# )r   r)   z0typing.Callable[[str], typing.Awaitable[object]]r   r   r   )r   s   "r   r   r   9   s      &V [_ r   c           	     &  "   V P                   ;_uu_ 4        \        V P                  4      pV P                  P                  4        ^ V n        RRR4       \        X4       F  w  pw  rE V! V4      G Rj  xL
  K  	  R#   + '       g   i     L:; i L  \         do    T P                   ;_uu_ 4        Y#R pY`P                  ,           T n        \        R T P                   4       4      T n        RRR4       h   + '       g   i     h ; ii ; i5i)z$Async variant of :meth:`flush_sync`.Nc              3  *   "   T F	  w  rVx  K  	  R # 5ir,   r   r-   s   &  r   r1   (SendQueue.flush_async.<locals>.<genexpr>G   r3   r4   r5   r;   s   &&     r   flush_asyncSendQueue.flush_async9   s     ZZZ4;;'GKKDK 
 (1'9#A#4j   (: Z ! ZZZ 'I"+kk"9DK"%%Bdkk%B"BDK   	  Z s^   D7B D*B5B6B:D B	DBD4=C:	1	D:D
	DDc                   V ^8  d   QhRR/# )r   r   z	list[str]r   )r   s   "r   r   r   J   s      y r   c                    V P                   ;_uu_ 4        V P                   UUu. uF  w  rVNK	  	  pppV P                  P                  4        ^ V n        VuuRRR4       # u uppi   + '       g   i     R# ; i)z&Remove and return all queued messages.N)r   r   r7   r   )r   r   r/   itemss   &   r   drainSendQueue.drainJ   sS    ZZZ)-5gdTE5KKDK	 Z5 ZZs   A(A"
%A("A((A9	c                   V ^8  d   QhRR/# )r   r   r
   r   )r   s   "r   r   r   R   s     $ $ $r   c                	    V P                   ;_uu_ 4        \        V P                  4      uuR R R 4       #   + '       g   i     R # ; ir,   r   r"   r   r   s   &r   __len__SendQueue.__len__R   s#    ZZZt{{# ZZZs	   5A	c                   V ^8  d   QhRR/# )r   r   boolr   )r   s   "r   r   r   V   s     ( ($ (r   c                	    V P                   ;_uu_ 4        \        V P                  4      ^ 8  uuRRR4       #   + '       g   i     R# ; ir   rO   rP   s   &r   __bool__SendQueue.__bool__V   s(    ZZZt{{#a' ZZZs	   8A		)r   r   r   r   N)i   )__name__
__module____qualname____firstlineno____doc__r   r&   r@   rF   rK   rQ   rV   __static_attributes__r   r   r   r   r   	   s/    &'*"$( (r   r   )
__future__r   typingr   _exceptionsr   r   r   r   r   <module>ra      s    "   0O( O(r   