Skip to contentSkip to conversation

bb/server/process.py: ProcessEventQueue add close of _writer pipe

PATCH New Aníbal Limón 1 participant 2 messages Jan 9, 2017

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 bb/server/process.py: ProcessEventQueue add close of _writer pipe

Call explicity close in _writer to avoid fd leakage because isn't called on Queue.close()

[YOCTO #10873]

---
 lib/bb/server/process.py | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
lib/bb/server/process.py +3 -1
index c9dfb4f..c3c1450 100644
@@ -233,6 +233,9 @@ class BitBakeProcessServerConnection(BitBakeBaseServerConnection):
         self.ui_channel.close()
         self.event_queue.close()
         self.event_queue.setexit()
+        # XXX: Call explicity close in _writer to avoid
+        # fd leakage because isn't called on Queue.close()
+        self.event_queue._writer.close()
 
 # Wrap Queue to provide API which isn't server implementation specific
 class ProcessEventQueue(multiprocessing.queues.Queue):
@@ -264,7 +267,6 @@ class ProcessEventQueue(multiprocessing.queues.Queue):
                 sys.exit(1)
             return None
 
-
 class BitBakeServer(BitBakeBaseServer):
     def initServer(self, single_use=True):
         # establish communication channels.  We use bidirectional pipes for
Signature · 1 line
2.1.4
#1 lore raw

PATCH 2/2 lib/bb/main.py: Shutdown cooker when server isn't foreground

The cooker is added to the BBServer and then detached creating a copy of the cooker in the process, if the server isn't in foreground it cause fd leaks on inotify this can be see using many instances of tinfoil.

Example:

from bb.tinfoil import Tinfoil
while True:

    with Tinfoil() as tinfoil:
        input("Pre\n")
        tinfoil.prepare(config_only=True)
        input("Post\n")

[YOCTO #10873]

---
 lib/bb/main.py | 1 +
 1 file changed, 1 insertion(+)
lib/bb/main.py +1 -0
index 443f5ec..3ff43cf 100755
@@ -367,6 +367,7 @@ def start_server(servermodule, configParams, configuration, features):
         raise
     if not configParams.foreground:
         server.detach()
+        cooker.shutdown()
     cooker.lock.close()
     return server
 
Signature · 1 line
2.1.4