summaryrefslogtreecommitdiff
path: root/COPYING.LESSER
diff options
context:
space:
mode:
authorDaniel P. Berrangé <berrange@redhat.com>2022-05-17 14:11:55 +0100
committerDaniel P. Berrangé <berrange@redhat.com>2022-06-08 16:43:52 +0100
commit376a9776598f5a5d44c70c7e844f5cab7e9bae2d (patch)
tree8d035ef9ceea2f74f8c4b64c0039c16fc8805e83 /COPYING.LESSER
parent30f8123072a8b665abcbd5d49c1ec69accd4f58c (diff)
downloadlibvirt-python-376a9776598f5a5d44c70c7e844f5cab7e9bae2d.tar.gz
libvirtio: lazy create the Event object in drain()
The drain method uses an asyncio.Event object to be notified when other coroutines have removed all registered callbacks. The Event object needs to be associated with the coroutine that the event loop is running with and currently this is achieved by passing in the 'loop' parameter. Unfortunately Python 3.10 has removed the 'loop' parameter and now the object is associated implicitly with the current thread's event loop. At the time the virEventAsyncIOImpl constructor is called, however, there is no guarantee that an event loop has been set for the thread. The explicitly passed in 'loop' parameter would handle this scenario. For portability with Python >= 3.10 we need to delay creation of the Event object until we have a guarantee that there is a loop associated with the current thread. This is achieved by lazily creating the Event object inside the 'drain' method, which is expected to be invoked from coroutine context and thus ensure a loop is associated. Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
Diffstat (limited to 'COPYING.LESSER')
0 files changed, 0 insertions, 0 deletions