B
    ‹æ@\¶  ã               @   sZ   d Z ddlmZmZmZmZ ddlZe e¡Z	ddl
mZ dZG dd„ deƒZd	d
„ ZdS )zg Bokeh Application Handler to look for Bokeh server lifecycle callbacks
in a specified Python module.

é    )Úabsolute_importÚdivisionÚprint_functionÚunicode_literalsNé   )ÚHandler)ÚLifecycleHandlerc                   sH   e Zd ZdZ‡ fdd„Zdd„ Zdd„ Zdd	„ Zd
d„ Zdd„ Z	‡  Z
S )r   z? Load a script which contains server lifecycle callbacks.

    c                s4   t t| ƒj||Ž t| _t| _t| _t| _d| _d S )NT)	Úsuperr   Ú__init__Ú_do_nothingÚ_on_server_loadedÚ_on_server_unloadedÚ_on_session_createdÚ_on_session_destroyedZsafe_to_fork)ÚselfÚargsÚkwargs)Ú	__class__© úClib/python3.7/site-packages/bokeh/application/handlers/lifecycle.pyr
   0   s    zLifecycleHandler.__init__c             C   s   dS )zø This handler does not make any modifications to the Document.

        Args:
            doc (Document) : A Bokeh Document to update in-place

                *This handler does not modify the document*

        Returns:
            None

        Nr   )r   Údocr   r   r   Úmodify_document:   s    z LifecycleHandler.modify_documentc             C   s
   |   |¡S )z¼ Execute `on_server_unloaded`` from the configured module (if
        it is defined) when the server is first started.

        Args:
            server_context (ServerContext) :

        )r   )r   Úserver_contextr   r   r   Úon_server_loadedI   s    z!LifecycleHandler.on_server_loadedc             C   s
   |   |¡S )aj   Execute ``on_server_unloaded`` from the configured module (if
        it is defined) when the server cleanly exits. (Before stopping the
        server's ``IOLoop``.)

        Args:
            server_context (ServerContext) :

        .. warning::
            In practice this code may not run, since servers are often killed
            by a signal.

        )r   )r   r   r   r   r   Úon_server_unloadedS   s    z#LifecycleHandler.on_server_unloadedc             C   s
   |   |¡S )z¼ Execute ``on_session_created`` from the configured module (if
        it is defined) when a new session is created.

        Args:
            session_context (SessionContext) :

        )r   )r   Úsession_contextr   r   r   Úon_session_createdb   s    z#LifecycleHandler.on_session_createdc             C   s
   |   |¡S )zÀ Execute ``on_session_destroyed`` from the configured module (if
        it is defined) when a new session is destroyed.

        Args:
            session_context (SessionContext) :

        )r   )r   r   r   r   r   Úon_session_destroyedl   s    z%LifecycleHandler.on_session_destroyed)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r
   r   r   r   r   r   Ú__classcell__r   r   )r   r   r   +   s   


r   c             C   s   d S )Nr   )Zignoredr   r   r   r   ~   s    r   )r!   Z
__future__r   r   r   r   ZloggingZ	getLoggerr   ÚlogZhandlerr   Ú__all__r   r   r   r   r   r   Ú<module>
   s   
S