
    -er                       d Z ddlmZ ddlZ ej        e          ZddlZddlm	Z	 ddl
mZmZmZmZmZmZmZ erddlmZ dd	lmZmZ d
Z ededef                   Z G d dee                   ZddZdZ G d d          ZdS )z

    )annotationsN)wraps)TYPE_CHECKINGAnyCallableLiteralProtocolTypeVarcast   )NextTickCallback   )CallbackDocument)UnlockedDocumentProxywithout_document_lockF.)boundc                  $    e Zd ZU ded<   ded<   dS )NoLockCallbackr   __call__zLiteral[True]nolockN)__name__
__module____qualname____annotations__     6lib/python3.11/site-packages/bokeh/document/locking.pyr   r   8   s'         KKKr   r   funcreturnNoLockCallback[F]c                     t          j                   rt                     d	 fd            }nt                     d	 fd            }t          t          t
                   |          }d|_        |S )
ap   Wrap a callback function to execute without first obtaining the
    document lock.

    Args:
        func (callable) : The function to wrap

    Returns:
        callable : a function wrapped to execute without a |Document| lock.

    While inside an unlocked callback, it is completely *unsafe* to modify
    ``curdoc()``. The value of ``curdoc()`` inside the callback will be a
    specially wrapped version of |Document| that only allows safe operations,
    which are:

    * :func:`~bokeh.document.Document.add_next_tick_callback`
    * :func:`~bokeh.document.Document.remove_next_tick_callback`

    Only these may be used safely without taking the document lock. To make
    other changes to the document, you must add a next tick callback and make
    your changes to ``curdoc()`` from that second callback.

    Attempts to otherwise access or change the Document will result in an
    exception being raised.

    ``func`` can be a synchronous function, an async function, or a function
    decorated with ``asyncio.coroutine``. The returned function will be an
    async function if ``func`` is any of the latter two.

    argsr   kwr!   Nonec                 (   K    | i | d {V  d S Nr   r$   r%   r    s     r   _wrapperz'without_document_lock.<locals>._wrapper[   s4      $############r   c                      | i | d S r(   r   r)   s     r   r*   z'without_document_lock.<locals>._wrapper_   s    D$"r   T)r$   r   r%   r   r!   r&   )asyncioiscoroutinefunctionr   r   r   r   r   )r    r*   wrappers   `  r   r   r   <   s    < "4(( 	t	$ 	$ 	$ 	$ 	$ 
	$ 	$ 
t	 	 	 	 	 
	 >!$h//GGNNr   zOnly 'add_next_tick_callback' may be used safely without taking the document lock; to make other changes to the document, add a next tick callback and make your changes from that callback.c                  2    e Zd ZdZddZdd
ZddZddZdS )r   z Wrap a Document object so that only methods that can safely be used
    from unlocked callbacks or threads are exposed. Attempts to otherwise
    access or change the Document results in an exception.

    docr   r!   r&   c                    || _         dS )


        N)_doc)selfr0   s     r   __init__zUnlockedDocumentProxy.__init__v   s     			r   attrstrr   c                *    t          t                    )r2   )AttributeErrorUNSAFE_DOC_ATTR_USAGE_MSG)r4   r6   s     r   __getattr__z!UnlockedDocumentProxy.__getattr__|   s     6777r   callbackr   r   c                6    | j                             |          S )zW Add a "next tick" callback.

        Args:
            callback (callable) :

        )r3   add_next_tick_callbackr4   r<   s     r   r>   z,UnlockedDocumentProxy.add_next_tick_callback   s     y//999r   c                :    | j                             |           dS )zZ Remove a "next tick" callback.

        Args:
            callback (callable) :

        N)r3   remove_next_tick_callbackr?   s     r   rA   z/UnlockedDocumentProxy.remove_next_tick_callback   s      		++H55555r   N)r0   r   r!   r&   )r6   r7   r!   r   )r<   r   r!   r   )r<   r   r!   r&   )r   r   r   __doc__r5   r;   r>   rA   r   r   r   r   r   o   sn            8 8 8 8: : : :6 6 6 6 6 6r   r   )r    r   r!   r"   )rB   
__future__r   logging	getLoggerr   logr,   	functoolsr   typingr   r   r   r   r	   r
   r   server.callbacksr   documentr   r   __all__r   r   r   r:   r   r   r   r   <module>rL      s    # " " " " " g!!                          -333333,,,,,,,, GCxS)***    Xa[   ) ) ) )Z #6 #6 #6 #6 #6 #6 #6 #6 #6 #6r   