bitbake: async: Close sync client event loop

Prevents `ResourceWarning: unclosed event loop` warnings when using the
synchronous client and python exits

(Bitbake rev: 8b95972bc04ce52a98c7780184af15a5e95f987b)

Signed-off-by: Joshua Watt <JPEWhacker@gmail.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
Joshua Watt
2021-10-06 21:57:06 -05:00
committed by Richard Purdie
parent baa7f7f62f
commit cac6facc9d
2 changed files with 8 additions and 2 deletions

View File

@@ -7,6 +7,7 @@ import asyncio
import json
import os
import socket
import sys
from . import chunkify, DEFAULT_MAX_CHUNK
@@ -129,7 +130,7 @@ class Client(object):
# required (but harmless) with it.
asyncio.set_event_loop(self.loop)
self._add_methods('connect_tcp', 'close', 'ping')
self._add_methods('connect_tcp', 'ping')
@abc.abstractmethod
def _get_async_client(self):
@@ -163,3 +164,9 @@ class Client(object):
@max_chunk.setter
def max_chunk(self, value):
self.client.max_chunk = value
def close(self):
self.loop.run_until_complete(self.client.close())
if sys.version_info >= (3, 6):
self.loop.run_until_complete(self.loop.shutdown_asyncgens())
self.loop.close()

View File

@@ -107,7 +107,6 @@ class Client(bb.asyncrpc.Client):
super().__init__()
self._add_methods(
"connect_tcp",
"close",
"get_unihash",
"report_unihash",
"report_unihash_equiv",