1
0
mirror of https://github.com/SpaceVim/SpaceVim.git synced 2025-01-24 05:30:07 +08:00
SpaceVim/bundle/deoplete.nvim/rplugin/python3/deoplete/process.py
2020-06-18 23:07:37 +08:00

34 lines
1.0 KiB
Python

# ============================================================================
# FILE: process.py
# AUTHOR: Shougo Matsushita <Shougo.Matsu at gmail.com>
# License: MIT license
# ============================================================================
import asyncio
import typing
class Process(asyncio.SubprocessProtocol):
def __init__(self, plugin: typing.Any) -> None:
self._plugin = plugin
self._vim = plugin._vim
def connection_made(self, transport: typing.Any) -> None:
self._unpacker = self._plugin._connect_stdin(
transport.get_pipe_transport(0))
def pipe_data_received(self, fd: int, data: typing.Any) -> None:
if fd == 2:
# stderr
self._plugin._queue_err.put(f'stderr from child process:{data}')
return
unpacker = self._unpacker
unpacker.feed(data)
for child_out in unpacker:
self._plugin._queue_out.put(child_out)
def process_exited(self) -> None:
self._plugin._queue_err.put('The child process is exited!')