cooker/siggen: Support exit calls and use for hashserv client
PATCH 1/3 cooker/siggen: Support exit calls and use for hashserv client
We have shutdown functions within the async client code but the siggen doesn't currently call them. We notice on python 3.10 (such as on fedora35) that at exit, there is a stray asyncio process left behind. Usually this doesn't cause problems but it could potentially be a cause of a hang.
For general cleanliness and completness, add in hooks to call the exit handler.
--- lib/bb/cooker.py | 1 + lib/bb/siggen.py | 9 +++++++++ 2 files changed, 10 insertions(+)
lib/bb/cooker.py +1 -0
@@ -1717,6 +1717,7 @@ class BBCooker: def post_serve(self): self.shutdown(force=True) prserv.serv.auto_shutdown() + bb.parse.siggen.exit() if self.hashserv: self.hashserv.process.terminate() self.hashserv.process.join()
lib/bb/siggen.py +9 -0
@@ -156,6 +156,9 @@ class SignatureGenerator(object): return DataCacheProxy() + def exit(self): + return + class SignatureGeneratorBasic(SignatureGenerator): """ """
@@ -489,6 +492,12 @@ class SignatureGeneratorUniHashMixIn(object): self._client = hashserv.create_client(self.server) return self._client + def exit(self): + if getattr(self, '_client', None) is not None: + self._client.close() + self._client = None + return super().exit() + def get_stampfile_hash(self, tid): if tid in self.taskhash: # If a unique hash is reported, use it as the stampfile hash. This
Signature · 1 line
2.32.0
PATCH 2/3 siggen: Add missing reset handler to hashserv signature generator
When we have a client connection, we should close that connection when reset() is called on the siggen. Add the missing function.
--- lib/bb/siggen.py | 6 ++++++ 1 file changed, 6 insertions(+)
lib/bb/siggen.py +6 -0
@@ -492,6 +492,12 @@ class SignatureGeneratorUniHashMixIn(object): self._client = hashserv.create_client(self.server) return self._client + def reset(self): + if getattr(self, '_client', None) is not None: + self._client.close() + self._client = None + return super().reset() + def exit(self): if getattr(self, '_client', None) is not None: self._client.close()
Signature · 1 line
2.32.0
PATCH 3/3 server/process: Move threads left debug to after cooker shutdown
In reply to Richard PurdieThis debug is useful but the cooker shutdown or post_serve() may have cleanup left so run after those.
--- lib/bb/server/process.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
lib/bb/server/process.py +3 -3
@@ -243,9 +243,6 @@ class ProcessServer(): ready = self.idle_commands(.1, fds) - if len(threading.enumerate()) != 1: - serverlog("More than one thread left?: " + str(threading.enumerate())) - serverlog("Exiting") # Remove the socket file so we don't get any more connections to avoid races try:
@@ -263,6 +260,9 @@ class ProcessServer(): self.cooker.post_serve() + if len(threading.enumerate()) != 1: + serverlog("More than one thread left?: " + str(threading.enumerate())) + # Flush logs before we release the lock sys.stdout.flush() sys.stderr.flush()
Signature · 1 line
2.32.0