aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoshua Watt <JPEWhacker@gmail.com>2021-10-06 21:57:06 -0500
committerRichard Purdie <richard.purdie@linuxfoundation.org>2021-10-11 10:58:44 +0100
commit8b95972bc04ce52a98c7780184af15a5e95f987b (patch)
tree39817c17589c7611a59e3ff7bc62522466c322a9
parentda543cdaf88a387675e25d3555765f1146e4105e (diff)
downloadbitbake-8b95972bc04ce52a98c7780184af15a5e95f987b.tar.gz
async: Close sync client event loop
Prevents `ResourceWarning: unclosed event loop` warnings when using the synchronous client and python exits Signed-off-by: Joshua Watt <JPEWhacker@gmail.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r--lib/bb/asyncrpc/client.py9
-rw-r--r--lib/hashserv/client.py1
2 files changed, 8 insertions, 2 deletions
diff --git a/lib/bb/asyncrpc/client.py b/lib/bb/asyncrpc/client.py
index 50e60d5c3..34960197d 100644
--- a/lib/bb/asyncrpc/client.py
+++ b/lib/bb/asyncrpc/client.py
@@ -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()
diff --git a/lib/hashserv/client.py b/lib/hashserv/client.py
index 1a67c6982..8cfd90d6a 100644
--- a/lib/hashserv/client.py
+++ b/lib/hashserv/client.py
@@ -107,7 +107,6 @@ class Client(bb.asyncrpc.Client):
super().__init__()
self._add_methods(
"connect_tcp",
- "close",
"get_unihash",
"report_unihash",
"report_unihash_equiv",