[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Making QEMU easier for management tools and applications
From: |
John Snow |
Subject: |
Re: Making QEMU easier for management tools and applications |
Date: |
Mon, 27 Jan 2020 14:41:00 -0500 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.3.0 |
On 1/25/20 6:41 AM, Paolo Bonzini wrote:
> On 20/01/20 10:55, Stefan Hajnoczi wrote:
>>>
>>> [1] https://qemu.readthedocs.io/en/latest/interop/live-block-operations.html
>> John and I discussed async events in the past. qmp-shell currently uses
>> the input() built-in function. If we modify it with a
>> select(2)/poll(2)-style function that monitors both stdin and the QMP
>> socket then it could print QMP events as soon as they are received.
>
> I think it should be rewritten using async/await. A simple example:
>
> import asyncio
> import sys
> from concurrent.futures import ThreadPoolExecutor
>
> async def ainput(prompt: str = ""):
> with ThreadPoolExecutor(1, "ainput") as executor:
> return (await asyncio.get_event_loop().run_in_executor(
> executor, sys.stdin.readline
> )).rstrip()
>
> async def numbers():
> i = 1
> while True:
> print(i)
> i = i + 1
> await asyncio.sleep(1)
>
> async def main():
> name = await ainput("What's your name? ")
> print("Hello, {}!".format(name))
>
> asyncio.get_event_loop().create_task(numbers())
> asyncio.get_event_loop().run_until_complete(main())
>
> This would be a great Summer of Code project. Even an autocompletion
> interface using readline should be possible.
>
> Paolo
>
I wrote an async version at one point; I had problems integrating
asyncio with readline functionality.
--js
Re: Making QEMU easier for management tools and applications, Dr. David Alan Gilbert, 2020/01/02
Re: Making QEMU easier for management tools and applications, Dr. David Alan Gilbert, 2020/01/02
Re: Making QEMU easier for management tools and applications, Kevin Wolf, 2020/01/07
Re: Making QEMU easier for management tools and applications, Christophe de Dinechin, 2020/01/07