ó
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 e f d „  ƒ  YZ d	 „  Z d S(   u_    Bokeh Application Handler to execute on_session_destroyed callbacks defined
on the Document.

i    (   t   absolute_importt   divisiont   print_functiont   unicode_literalsNi   (   t   LifecycleHandleru   DocumentLifecycleHandlert   DocumentLifecycleHandlerc           B` s   e  Z d  Z d „  Z RS(   uD    Calls on_session_destroyed callbacks defined on the Document.

    c         O` s&   t  t |  ƒ j | | Ž  t |  _ d  S(   N(   t   superR   t   __init__t   _on_session_destroyed(   t   selft   argst   kwargs(    (    sL   lib/python2.7/site-packages/bokeh/application/handlers/document_lifecycle.pyR   0   s    (   t   __name__t
   __module__t   __doc__R   (    (    (    sL   lib/python2.7/site-packages/bokeh/application/handlers/document_lifecycle.pyR   +   s   c         C` s   |  j  j } t ƒ  |  j  _ xI | D]A } y | |  ƒ Wq" t k
 rb } t j d | | f ƒ q" Xq" W| rŒ ~ ~ d d l } | j ƒ  n  d S(   uJ   
    Calls any on_session_destroyed callbacks defined on the Document
    uY   DocumentLifeCycleHandler on_session_destroyed callback %s failed with following error: %si    N(   t	   _documentt   session_destroyed_callbackst   sett	   Exceptiont   logt   warningt   gct   collect(   t   session_contextt	   callbackst   callbackt   eR   (    (    sL   lib/python2.7/site-packages/bokeh/application/handlers/document_lifecycle.pyR   <   s    	(   u   DocumentLifecycleHandler(   R   t
   __future__R    R   R   R   t   loggingt	   getLoggerR   R   t	   lifecycleR   t   __all__R   R   (    (    (    sL   lib/python2.7/site-packages/bokeh/application/handlers/document_lifecycle.pyt   <module>
   s   "