@@ -90,6 +90,7 @@ class ProcessServer():
self.idle = None
self._idlefuns = {}
+ self.is_idle = threading.Event()
self.bitbake_lock = lock
self.bitbake_lock_name = lockname
@@ -169,6 +170,13 @@ class ProcessServer():
self.controllersock.close()
self.controllersock = False
if self.haveui:
+ # Wait for the idle loop to have cleared (30s max)
+ self.is_idle.clear()
+ self.is_idle.wait(timeout=30)
+ if self.cooker.command.currentAsyncCommand is not None:
+ serverlog("Idle loop didn't finish queued commands after 30s, exiting.")
+ self.quit = True
+
fds.remove(self.command_channel)
bb.event.unregister_UIHhandler(self.event_handle, True)
self.command_channel_reply.writer.close()
@@ -180,7 +188,7 @@ class ProcessServer():
self.cooker.clientComplete()
self.haveui = False
ready = select.select(fds,[],[],0)[0]
- if newconnections:
+ if newconnections and not self.quit:
serverlog("Starting new client")
conn = newconnections.pop(-1)
fds.append(conn)
@@ -384,6 +392,10 @@ class ProcessServer():
del self._idlefuns[function]
self.quit = True
+ # FIXME - the 1 is the inotify processing in cooker which always runs
+ if len(self._idlefuns) <= 1:
+ self.is_idle.set()
+
if nextsleep is not None:
select.select(fds,[],[],nextsleep)[0]
When clients are disconnecting, we need to ensure things are in sync with the idle thread. Use a threading event to show when things drop back to idle (there is only one always present idle handler for inotify). Later patches should be able to clean up the inotify handler to work differently and avoid hardcoded values. If we're not idle at client disconnect, shut down the server to solve the dilemma. Not ideal but shouldn't happen much in practise and would be restarted. Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org> --- lib/bb/server/process.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-)