[libvirt] [PATCH v2 6/6] libvirtaio: add .drain() coroutine
Wojtek Porczyk
woju at invisiblethingslab.com
Mon Sep 25 22:47:00 UTC 2017
On Mon, Sep 25, 2017 at 02:53:01PM +0100, Daniel P. Berrange wrote:
> On Thu, Sep 14, 2017 at 02:41:12AM +0200, Wojtek Porczyk wrote:
> > The intended use is to ensure that the implementation is empty, which is
> > one way to ensure that all connections were properly closed and file
> > descriptors reclaimed.
> >
> > Signed-off-by: Wojtek Porczyk <woju at invisiblethingslab.com>
> > ---
(snip)
> > + @asyncio.coroutine
> > + def drain(self):
> > + '''Wait for the implementation to become idle.
> > +
> > + This is a coroutine.
> > + '''
> > + self.log.debug('drain()')
> > + if self._pending:
> > + yield from self._finished.wait()
> > + self.log.debug('drain ended')
>
> What is responsible for calling 'drain' ?
Users of the library, and they do it at their pleasure. This is to allow the
loop to actually run the scheduled tasks. After calling virConnect.close() the
handles/timeouts aren't actually closed until the loop run the scheduled
callbacks. In practice a simple `yield` in a coroutine would be also
sufficient since respective Tasks are in the _ready queue and all run during
next loop cycle, but that's not guaranteed in asyncio specification.
--
pozdrawiam / best regards _.-._
Wojtek Porczyk .-^' '^-.
Invisible Things Lab |'-.-^-.-'|
| | | |
I do not fear computers, | '-.-' |
I fear lack of them. '-._ : ,-'
-- Isaac Asimov `^-^-_>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20170926/8ae4e1a7/attachment-0001.sig>
More information about the libvir-list
mailing list