
On Tue, Sep 26, 2017 at 12:47:00AM +0200, Wojtek Porczyk wrote:
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@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.
Ah I see. Reviewed-by: Daniel P. Berrange <berrange@redhat.com> Regards, Daniel -- |: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|