From c4ecfc4dc5511a23e12ed68eb140a67fd4181127 Mon Sep 17 00:00:00 2001 From: Richard Purdie Date: Thu, 29 Dec 2022 14:56:14 +0000 Subject: bitbake: server/process: Improve idle loop exit code When idle handlers want to exit, returning "False" isn't very clear and also causes challenges with the ordering of the removing the idle handler and marking that no async command is running. Use a specific class to signal the exit condition allowing clearer code and allowing the async command to be cleared after the handler has been removed, reducing any opportunity for races. (Bitbake rev: 102e8d0d4c5c0dd8c7ba09ad26589deec77e4308) Signed-off-by: Richard Purdie --- bitbake/lib/bb/server/process.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'bitbake/lib/bb/server') diff --git a/bitbake/lib/bb/server/process.py b/bitbake/lib/bb/server/process.py index eba28ad983..5acc105e08 100644 --- a/bitbake/lib/bb/server/process.py +++ b/bitbake/lib/bb/server/process.py @@ -71,6 +71,10 @@ def get_lockfile_process_msg(lockfile): return procs.decode("utf-8") return None +class idleFinish(): + def __init__(self, msg): + self.msg = msg + class ProcessServer(): profile_filename = "profile.log" profile_processed_filename = "profile.log.processed" @@ -361,7 +365,12 @@ class ProcessServer(): for function, data in list(self._idlefuns.items()): try: retval = function(self, data, False) - if retval is False: + if isinstance(retval, idleFinish): + serverlog("Removing idle function %s at idleFinish" % str(function)) + del self._idlefuns[function] + self.cooker.command.finishAsyncCommand(retval.msg) + nextsleep = None + elif retval is False: serverlog("Removing idle function %s" % str(function)) del self._idlefuns[function] nextsleep = None -- cgit v1.2.3-54-g00ecf