diff options
author | Richard Purdie <richard.purdie@linuxfoundation.org> | 2023-01-11 16:09:22 +0000 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2023-01-11 23:16:31 +0000 |
commit | e26e0b92e813bea0d5b875c936ff390937c860f0 (patch) | |
tree | 029f223f8b02aad28d1a6be28b4ccae2495e7d63 /bitbake | |
parent | 29cfebf4e0312ec3cffcea08a7b7cbfecbc7d4e2 (diff) | |
download | poky-e26e0b92e813bea0d5b875c936ff390937c860f0.tar.gz |
bitbake: server/process: Move heartbeat to idle thread
Rather than risk the heartbeat event code locking up the server control
socket, handle it in the 'idle' thread with the other work. The aim
is to remove it as a possible issue with some ongoing hangs.
(Bitbake rev: 0f9a0c7853b181817bf01863a26da21412376294)
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake')
-rw-r--r-- | bitbake/lib/bb/server/process.py | 44 |
1 files changed, 22 insertions, 22 deletions
diff --git a/bitbake/lib/bb/server/process.py b/bitbake/lib/bb/server/process.py index a25f04d148..529196b78c 100644 --- a/bitbake/lib/bb/server/process.py +++ b/bitbake/lib/bb/server/process.py | |||
@@ -439,6 +439,28 @@ class ProcessServer(): | |||
439 | serverlog("Exception %s broke the idle_thread, exiting" % traceback.format_exc()) | 439 | serverlog("Exception %s broke the idle_thread, exiting" % traceback.format_exc()) |
440 | self.quit = True | 440 | self.quit = True |
441 | 441 | ||
442 | # Create new heartbeat event? | ||
443 | now = time.time() | ||
444 | if bb.event._heartbeat_enabled and now >= self.next_heartbeat: | ||
445 | # We might have missed heartbeats. Just trigger once in | ||
446 | # that case and continue after the usual delay. | ||
447 | self.next_heartbeat += self.heartbeat_seconds | ||
448 | if self.next_heartbeat <= now: | ||
449 | self.next_heartbeat = now + self.heartbeat_seconds | ||
450 | if hasattr(self.cooker, "data"): | ||
451 | heartbeat = bb.event.HeartbeatEvent(now) | ||
452 | try: | ||
453 | bb.event.fire(heartbeat, self.cooker.data) | ||
454 | except Exception as exc: | ||
455 | if not isinstance(exc, bb.BBHandledException): | ||
456 | logger.exception('Running heartbeat function') | ||
457 | serverlog("Exception %s broke in idle_thread, exiting" % traceback.format_exc()) | ||
458 | self.quit = True | ||
459 | if nextsleep and bb.event._heartbeat_enabled and now + nextsleep > self.next_heartbeat: | ||
460 | # Shorten timeout so that we we wake up in time for | ||
461 | # the heartbeat. | ||
462 | nextsleep = self.next_heartbeat - now | ||
463 | |||
442 | if nextsleep is not None: | 464 | if nextsleep is not None: |
443 | select.select(fds,[],[],nextsleep)[0] | 465 | select.select(fds,[],[],nextsleep)[0] |
444 | 466 | ||
@@ -451,28 +473,6 @@ class ProcessServer(): | |||
451 | self.idle = threading.Thread(target=self.idle_thread) | 473 | self.idle = threading.Thread(target=self.idle_thread) |
452 | self.idle.start() | 474 | self.idle.start() |
453 | 475 | ||
454 | # Create new heartbeat event? | ||
455 | now = time.time() | ||
456 | if bb.event._heartbeat_enabled and now >= self.next_heartbeat: | ||
457 | # We might have missed heartbeats. Just trigger once in | ||
458 | # that case and continue after the usual delay. | ||
459 | self.next_heartbeat += self.heartbeat_seconds | ||
460 | if self.next_heartbeat <= now: | ||
461 | self.next_heartbeat = now + self.heartbeat_seconds | ||
462 | if hasattr(self.cooker, "data"): | ||
463 | heartbeat = bb.event.HeartbeatEvent(now) | ||
464 | try: | ||
465 | bb.event.fire(heartbeat, self.cooker.data) | ||
466 | except Exception as exc: | ||
467 | if not isinstance(exc, bb.BBHandledException): | ||
468 | logger.exception('Running heartbeat function') | ||
469 | serverlog("Exception %s broke in idle_commands, exiting" % traceback.format_exc()) | ||
470 | self.quit = True | ||
471 | if nextsleep and bb.event._heartbeat_enabled and now + nextsleep > self.next_heartbeat: | ||
472 | # Shorten timeout so that we we wake up in time for | ||
473 | # the heartbeat. | ||
474 | nextsleep = self.next_heartbeat - now | ||
475 | |||
476 | if nextsleep is not None: | 476 | if nextsleep is not None: |
477 | if self.xmlrpc: | 477 | if self.xmlrpc: |
478 | nextsleep = self.xmlrpc.get_timeout(nextsleep) | 478 | nextsleep = self.xmlrpc.get_timeout(nextsleep) |