def create_asyncio_event_loop(loop=None): """ 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.) """ AsyncioEventLoop = _get_asyncio_loop_cls() return AsyncioEventLoop(loop)
def create_asyncio_eventloop(loop=None): """ Returns an asyncio `Eventloop` instance for usage in a `CommandLineInterface`. It is a wrapper around an asyncio loop. :param loop: The asyncio eventloop (or `None` if the default asyncioloop should be used.) """ # Inline import, to make sure the rest doesn't break on Python 2. (Where # asyncio is not available.) if is_windows(): from prompt_toolkit.eventloop.asyncio_win32 import Win32AsyncioEventLoop as AsyncioEventLoop else: from prompt_toolkit.eventloop.asyncio_posix import PosixAsyncioEventLoop as AsyncioEventLoop return AsyncioEventLoop(loop)
def read_input_async(self, on_abort=AbortAction.RETRY, on_exit=AbortAction.IGNORE): """ Same as `read_input`, but this returns an asyncio coroutine. Warning: this will only work on Python >3.3 """ # Inline import, to make sure the rest doesn't break on Python 2 if sys.platform == 'win32': from prompt_toolkit.eventloop.asyncio_win32 import Win32AsyncioEventLoop as AsyncioEventLoop else: from prompt_toolkit.eventloop.asyncio_posix import PosixAsyncioEventLoop as AsyncioEventLoop eventloop = AsyncioEventLoop(self.input_processor, self.stdin) return self._read_input(on_abort=on_abort, on_exit=on_exit, eventloop=eventloop, return_corountine=True)