bitbake-devel.lists.openembedded.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/4] async: Close sync client event loop
@ 2021-10-11  9:58 Richard Purdie
  2021-10-11  9:58 ` [PATCH 2/4] hashserv: Add tests for diverging reports Richard Purdie
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Richard Purdie @ 2021-10-11  9:58 UTC (permalink / raw)
  To: bitbake-devel; +Cc: Joshua Watt

From: Joshua Watt <JPEWhacker@gmail.com>

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>
---
 lib/bb/asyncrpc/client.py | 9 ++++++++-
 lib/hashserv/client.py    | 1 -
 2 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/lib/bb/asyncrpc/client.py b/lib/bb/asyncrpc/client.py
index 50e60d5c31..34960197d1 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 1a67c6982d..8cfd90d6a8 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",
-- 
2.32.0



^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-10-11  9:59 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-11  9:58 [PATCH 1/4] async: Close sync client event loop Richard Purdie
2021-10-11  9:58 ` [PATCH 2/4] hashserv: Add tests for diverging reports Richard Purdie
2021-10-11  9:58 ` [PATCH 3/4] hashserv: Fix diverging report race condition Richard Purdie
2021-10-11  9:58 ` [PATCH 4/4] hashserv: Improve behaviour for better determinism/sstate reuse Richard Purdie

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).