ó
mÜJ]c           @` s‚   d  Z  d d l m Z m Z m Z m Z d d l Z e j e ƒ Z	 d d l
 m Z d Z d „  Z d	 Z d
 e f d „  ƒ  YZ d S(   u   

i    (   t   absolute_importt   divisiont   print_functiont   unicode_literalsNi   (   t   wrapsu   UnlockedDocumentProxyu   without_document_lockc         ` s(   t  ˆ  ƒ ‡  f d †  ƒ } t | _ | S(   už   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.

    c          ` s   ˆ  |  | Ž  S(   N(    (   t   argst   kw(   t   func(    s5   lib/python2.7/site-packages/bokeh/document/locking.pyt   wrapperE   s    (   R   t   Truet   nolock(   R   R   (    (   R   s5   lib/python2.7/site-packages/bokeh/document/locking.pyt   without_document_lock+   s    	u¼   Only '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.t   UnlockedDocumentProxyc           B` s2   e  Z d  Z d „  Z d „  Z d „  Z d „  Z RS(   uÏ    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.

    c         C` s   | |  _  d S(   u
   

        N(   t   _doc(   t   selft   doc(    (    s5   lib/python2.7/site-packages/bokeh/document/locking.pyt   __init__X   s    c         C` s   t  t ƒ ‚ d S(   u
   

        N(   t   RuntimeErrort   UNSAFE_DOC_ATTR_USAGE_MSG(   R   t   attr(    (    s5   lib/python2.7/site-packages/bokeh/document/locking.pyt   __getattr__^   s    c         C` s   |  j  j | ƒ S(   uW    Add a "next tick" callback.

        Args:
            callback (callable) :

        (   R   t   add_next_tick_callback(   R   t   callback(    (    s5   lib/python2.7/site-packages/bokeh/document/locking.pyR   d   s    c         C` s   |  j  j | ƒ S(   uZ    Remove a "next tick" callback.

        Args:
            callback (callable) :

        (   R   t   remove_next_tick_callback(   R   R   (    (    s5   lib/python2.7/site-packages/bokeh/document/locking.pyR   m   s    (   t   __name__t
   __module__t   __doc__R   R   R   R   (    (    (    s5   lib/python2.7/site-packages/bokeh/document/locking.pyR   Q   s
   				(   u   UnlockedDocumentProxyu   without_document_lock(   R   t
   __future__R    R   R   R   t   loggingt	   getLoggerR   t   logt   util.futureR   t   __all__R   R   t   objectR   (    (    (    s5   lib/python2.7/site-packages/bokeh/document/locking.pyt   <module>	   s   " 	!