summaryrefslogtreecommitdiff
path: root/poky/bitbake/lib/bb/server/process.py
diff options
context:
space:
mode:
Diffstat (limited to 'poky/bitbake/lib/bb/server/process.py')
-rw-r--r--poky/bitbake/lib/bb/server/process.py30
1 files changed, 24 insertions, 6 deletions
diff --git a/poky/bitbake/lib/bb/server/process.py b/poky/bitbake/lib/bb/server/process.py
index 1636616660..ce53fdc678 100644
--- a/poky/bitbake/lib/bb/server/process.py
+++ b/poky/bitbake/lib/bb/server/process.py
@@ -20,6 +20,7 @@ import os
import sys
import time
import select
+import signal
import socket
import subprocess
import errno
@@ -243,9 +244,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 +261,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()
@@ -556,7 +557,7 @@ def execServer(lockfd, readypipeinfd, lockname, sockname, server_timeout, xmlrpc
server.run()
finally:
- # Flush any ,essages/errors to the logfile before exit
+ # Flush any messages/errors to the logfile before exit
sys.stdout.flush()
sys.stderr.flush()
@@ -737,11 +738,28 @@ class ConnectionWriter(object):
# Why bb.event needs this I have no idea
self.event = self
- def send(self, obj):
- obj = multiprocessing.reduction.ForkingPickler.dumps(obj)
+ def _send(self, obj):
with self.wlock:
self.writer.send_bytes(obj)
+ def send(self, obj):
+ obj = multiprocessing.reduction.ForkingPickler.dumps(obj)
+ # See notes/code in CookerParser
+ # We must not terminate holding this lock else processes will hang.
+ # For SIGTERM, raising afterwards avoids this.
+ # For SIGINT, we don't want to have written partial data to the pipe.
+ # pthread_sigmask block/unblock would be nice but doesn't work, https://bugs.python.org/issue47139
+ process = multiprocessing.current_process()
+ if process and hasattr(process, "queue_signals"):
+ with process.signal_threadlock:
+ process.queue_signals = True
+ self._send(obj)
+ process.queue_signals = False
+ for sig in process.signal_received.pop():
+ process.handle_sig(sig, None)
+ else:
+ self._send(obj)
+
def fileno(self):
return self.writer.fileno()