mirror of
https://gitlab.com/libvirt/libvirt-python.git
synced 2024-10-26 07:55:06 +03:00
libvirtaio: add better docs on best practice usage pattern
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
This commit is contained in:
parent
376a977659
commit
c2fae558c3
@ -21,8 +21,27 @@
|
||||
|
||||
Register the implementation of default loop:
|
||||
|
||||
>>> import libvirtaio
|
||||
>>> libvirtaio.virEventRegisterAsyncIOImpl()
|
||||
import asyncio
|
||||
import libvirtaio
|
||||
|
||||
async def myapp():
|
||||
libvirtaio.virEventRegisterAsyncIOImpl()
|
||||
|
||||
conn = libvirt.open("test:///default")
|
||||
|
||||
For compatibility with Python < 3.7:
|
||||
|
||||
loop = asyncio.new_event_loop()
|
||||
asyncio.set_event_loop(loop)
|
||||
|
||||
loop.run_until_complete(myapp())
|
||||
|
||||
asyncio.set_event_loop(None)
|
||||
loop.close()
|
||||
|
||||
If Python >= 3.7 can be required then
|
||||
|
||||
asyncio.run(myapp())
|
||||
|
||||
.. seealso::
|
||||
https://libvirt.org/html/libvirt-libvirt-event.html
|
||||
|
Loading…
Reference in New Issue
Block a user