|
1 | 1 | from __future__ import unicode_literals |
2 | 2 | import json |
3 | 3 |
|
| 4 | +from asyncio import ensure_future |
4 | 5 | from prompt_toolkit.application.current import set_app |
5 | | -from prompt_toolkit.eventloop import ensure_future, From |
6 | 6 | from prompt_toolkit.input.vt100_parser import Vt100Parser |
7 | | -from prompt_toolkit.layout.screen import Size |
| 7 | +from prompt_toolkit.data_structures import Size |
8 | 8 | from prompt_toolkit.output.vt100 import Vt100_Output |
9 | 9 | from prompt_toolkit.utils import is_windows |
10 | 10 |
|
@@ -40,10 +40,10 @@ def feed_key(key): |
40 | 40 |
|
41 | 41 | ensure_future(self._start_reading()) |
42 | 42 |
|
43 | | - def _start_reading(self): |
| 43 | + async def _start_reading(self): |
44 | 44 | while True: |
45 | 45 | try: |
46 | | - data = yield From(self.pipe_connection.read()) |
| 46 | + data = await self.pipe_connection.read() |
47 | 47 | self._process(data) |
48 | 48 | except BrokenPipeError: |
49 | 49 | self.detach_and_close() |
@@ -105,9 +105,9 @@ def _send_packet(self, data): |
105 | 105 |
|
106 | 106 | data = json.dumps(data) |
107 | 107 |
|
108 | | - def send(): |
| 108 | + async def send(): |
109 | 109 | try: |
110 | | - yield From(self.pipe_connection.write(data)) |
| 110 | + await self.pipe_connection.write(data) |
111 | 111 | except BrokenPipeError: |
112 | 112 | self.detach_and_close() |
113 | 113 | ensure_future(send()) |
@@ -147,15 +147,14 @@ def _create_app(self, color_depth, term='xterm'): |
147 | 147 | self.client_state = self.pymux.add_client( |
148 | 148 | input=self._pipeinput, output=output, connection=self, color_depth=color_depth) |
149 | 149 |
|
150 | | - print('Start running app...') |
151 | | - future = self.client_state.app.run_async() |
152 | | - print('Start running app got future...', future) |
| 150 | + async def run(): |
| 151 | + print('Start running app...') |
| 152 | + future = await self.client_state.app.run_async() |
153 | 153 |
|
154 | | - @future.add_done_callback |
155 | | - def done(_): |
156 | 154 | print('APP DONE.........') |
157 | 155 | print(future.result()) |
158 | 156 | self._close_connection() |
| 157 | + ensure_future(run()) |
159 | 158 |
|
160 | 159 | def _close_connection(self): |
161 | 160 | # This is important. If we would forget this, the server will |
|
0 commit comments