Bug #336644 - Make EbuildIpcDaemon use AbstractPollTask._read_buf(),
authorZac Medico <zmedico@gentoo.org>
Fri, 10 Sep 2010 03:49:50 +0000 (20:49 -0700)
committerZac Medico <zmedico@gentoo.org>
Fri, 10 Sep 2010 03:49:50 +0000 (20:49 -0700)
for better handling of errors like "IOError: [Errno 11] Resource
temporarily unavailable". TODO: Apply a similar fix to ebuild-ipc.py.

pym/_emerge/EbuildIpcDaemon.py

index 93333a6b170e72ae9f17d624ee89bc5dc6ddff43..f6bfecfbe1e4e7c0bd8688f8618c36f2040e2c77 100644 (file)
@@ -29,26 +29,13 @@ class EbuildIpcDaemon(FifoIpcDaemon):
        __slots__ = ('commands',)
 
        def _input_handler(self, fd, event):
+               # Read the whole pickle in a single atomic read() call.
+               buf = self._read_buf(self._files.pipe_in, event)
 
-               if event & PollConstants.POLLIN:
-
-                       # Read the whole pickle in a single read() call since
-                       # this stream is in non-blocking mode and pickle.load()
-                       # has been known to raise the following exception when
-                       # reading from a non-blocking stream:
-                       #
-                       #   File "/usr/lib64/python2.6/pickle.py", line 1370, in load
-                       #     return Unpickler(file).load()
-                       #   File "/usr/lib64/python2.6/pickle.py", line 858, in load
-                       #     dispatch[key](self)
-                       #   File "/usr/lib64/python2.6/pickle.py", line 1195, in load_setitem
-                       #     value = stack.pop()
-                       # IndexError: pop from empty list
-
-                       pickle_str = self._files.pipe_in.read()
+               if buf:
 
                        try:
-                               obj = pickle.loads(pickle_str)
+                               obj = pickle.loads(buf.tostring())
                        except (EnvironmentError, EOFError, ValueError,
                                pickle.UnpicklingError):
                                pass