Skip to contentSkip to conversation

utils.py: Add function to set nonblocking operation on a file descriptor

PATCH New Richard Purdie 1 participant 1 message Jun 22, 2012

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 utils.py: Add function to set nonblocking operation on a file descriptor

---

bitbake/lib/bb/runqueue.py +1 -1
index 1d9bdf0..03766ad 100644
@@ -1736,7 +1736,7 @@ class runQueuePipe():
     def __init__(self, pipein, pipeout, d):
         self.input = pipein
         pipeout.close()
-        fcntl.fcntl(self.input, fcntl.F_SETFL, fcntl.fcntl(self.input, fcntl.F_GETFL) | os.O_NONBLOCK)
+        bb.utils.nonblockingfd(self.input)
         self.queue = ""
         self.d = d
 
bitbake/lib/bb/utils.py +5 -0
index fc389a3..77ad39e 100644
@@ -26,6 +26,7 @@ import logging
 import bb
 import bb.msg
 import multiprocessing
+import fcntl
 from commands import getstatusoutput
 from contextlib import contextmanager
 
@@ -754,3 +755,7 @@ def contains(variable, checkvalues, truevalue, falsevalue, d):
 
 def cpu_count():
     return multiprocessing.cpu_count()
+
+def nonblockingfd(fd):
+    fcntl.fcntl(fd, fcntl.F_SETFL, fcntl.fcntl(fd, fcntl.F_GETFL) | os.O_NONBLOCK)
+