U
    õÕ/ex  ã                   @  s‚   d Z ddlmZ ddlZe e¡ZddlmZm	Z	 ddl
mZ ddlmZmZ d	d
lmZ dZG dd„ deƒZdddœdd„ZdS )zg Bokeh Application Handler to look for Bokeh server lifecycle callbacks
in a specified Python module.

é    )ÚannotationsN)ÚAnyÚCallableé   )ÚDocumenté   )ÚServerContextÚSessionContexté   )ÚHandler)ÚLifecycleHandlerc                      sª   e Zd ZU dZded< ded< ded< ded< dd	œ‡ fd
d„Zedd	œdd„ƒZdddœdd„Zdddœdd„Z	dddœdd„Z
dddœdd„Zdddœdd„Z‡  ZS )r   zV Load a script which contains server lifecycle callbacks.

    .. autoclasstoc::

    zCallable[[ServerContext], None]Ú_on_server_loadedÚ_on_server_unloadedz Callable[[SessionContext], None]Ú_on_session_createdÚ_on_session_destroyedÚNone)Úreturnc                   s&   t ƒ  ¡  t| _t| _t| _t| _d S ©N)ÚsuperÚ__init__Ú_do_nothingr   r   r   r   ©Úself©Ú	__class__© úH/tmp/pip-unpacked-wheel-f5fndrjf/bokeh/application/handlers/lifecycle.pyr   8   s
    
zLifecycleHandler.__init__Úboolc                 C  s   dS )NTr   r   r   r   r   Úsafe_to_fork?   s    zLifecycleHandler.safe_to_forkr   )Údocr   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   r   r   r   r   Úmodify_documentE   s    z LifecycleHandler.modify_documentr   )Úserver_contextr   c                 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   r!   r   r   r   Úon_server_loadedT   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   Úon_server_unloaded^   s    z#LifecycleHandler.on_server_unloadedr	   )Úsession_contextr   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   r%   r   r   r   Úon_session_createdm   s    z#LifecycleHandler.on_session_createdc                 Ã  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   Úon_session_destroyedw   s    z%LifecycleHandler.on_session_destroyed)Ú__name__Ú
__module__Ú__qualname__Ú__doc__Ú__annotations__r   Úpropertyr   r    r#   r$   r'   r(   Ú__classcell__r   r   r   r   r   ,   s   


r   r   r   )Úignoredr   c                 C  s   d S r   r   )r0   r   r   r   r   ‰   s    r   )r,   Ú
__future__r   ÚloggingÚ	getLoggerr)   ÚlogÚtypingr   r   Údocumentr   Zapplicationr   r	   Úhandlerr   Ú__all__r   r   r   r   r   r   Ú<module>   s   
]