pvl.syslog.fifo: refactor read
authorTero Marttila <terom@paivola.fi>
Sun, 13 Jan 2013 03:11:25 +0200
changeset 125 9925ef5258f1
parent 124 be4519fe014d
child 126 bf2555ae7d06
pvl.syslog.fifo: refactor read
pvl/syslog/fifo.py
--- a/pvl/syslog/fifo.py	Sun Jan 13 02:47:13 2013 +0200
+++ b/pvl/syslog/fifo.py	Sun Jan 13 03:11:25 2013 +0200
@@ -50,7 +50,8 @@
             raise ValueError("I/O operation on closed pipe: %s" % (self, ))
         else :
             return self._fd
-
+    
+    # XXX: this is almost identical to pvl.socket.ReadStream
     def read (self, n=512) :
         """
             Read up to n bytes.
@@ -66,13 +67,16 @@
             # block?
             if ex.errno == errno.EAGAIN :
                 # empty
-                return None
+                buf = None
 
             else :
                 raise
 
-        # eof?
-        if buf :
+        log.debug("%s: %s", self, buf)
+
+        if buf is None :
+            return None
+        elif buf :
             return buf
         else :
             raise EOFError()