B
    't\"                 @   s   d dl mZ d dlmZ ddlmZ d dlZdddd	d
dddgZdddZdd Z	dddZ
dddZdae Zdd	 Zdd
 ZdddZdddZdddZdS )     )unicode_literals)
is_windows   )	EventLoopNcreate_event_loopcreate_asyncio_event_loopuse_asyncio_event_loopget_event_loopset_event_looprun_in_executorcall_from_executorrun_until_completeTc             C   s2   t  rddlm} || dS ddlm} | S dS )z^
    Create and return an
    :class:`~prompt_toolkit.eventloop.base.EventLoop` instance.
    r   )Win32EventLoop)Zrecognize_paste)PosixEventLoopN)r   Zwin32r   posixr   )Zrecognize_win32_paster   r    r   @lib/python3.7/site-packages/prompt_toolkit/eventloop/defaults.pyr      s
    
c              C   s$   t  rddlm}  nddlm}  | S )Nr   )Win32AsyncioEventLoop)PosixAsyncioEventLoop)r   Z&prompt_toolkit.eventloop.asyncio_win32r   Z&prompt_toolkit.eventloop.asyncio_posixr   )AsyncioEventLoopr   r   r   _get_asyncio_loop_cls   s    r   c             C   s   t  }|| S )a3  
    Returns an asyncio :class:`~prompt_toolkit.eventloop.EventLoop` instance
    for usage in a :class:`~prompt_toolkit.application.Application`. It is a
    wrapper around an asyncio loop.

    :param loop: The asyncio eventloop (or `None` if the default asyncioloop
                 should be used.)
    )r   )loopr   r   r   r   r   )   s    	c             C   s*   t  }|rt|t rdS tt|  dS )zE
    Use the asyncio event loop for prompt_toolkit applications.
    N)r	   
isinstancer   r
   r   )r   Zcurrent_loopr   r   r   r   6   s    c            	   C   s"   t  tdkrt atS Q R X dS )z`
    Return the current event loop.
    This will create a new loop if no loop was set yet.
    N)
_loop_lock_loopr   r   r   r   r   r	   F   s    	c             C   s   | dkst | tst| adS )z
    Set the current event loop.

    :param loop: `EventLoop` instance or None. (Pass `None` to clear the
        current loop.)
    N)r   r   AssertionErrorr   )r   r   r   r   r
   [   s    Fc             C   s   t  j| |dS )z=
    Run a long running function in a background thread.
    )_daemon)r	   r   )callbackr   r   r   r   r   g   s    c             C   s   t  j| |dS )z4
    Call this function in the main event loop.
    )_max_postpone_until)r	   r   )r   r   r   r   r   r   n   s    c             C   s   t  j| |dS )zn
    Keep running until this future has been set.
    Return the Future's result, or raise its exception.
    )	inputhook)r	   r   )Zfuturer   r   r   r   r   v   s    )T)N)N)F)N)N)Z
__future__r   Zprompt_toolkit.utilsr   baser   Z	threading__all__r   r   r   r   r   RLockr   r	   r
   r   r   r   r   r   r   r   <module>   s,   





