From: Zac Medico Date: Fri, 10 Sep 2010 03:49:50 +0000 (-0700) Subject: Bug #336644 - Make EbuildIpcDaemon use AbstractPollTask._read_buf(), X-Git-Tag: v2.2_rc79~17 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=34cd7af0911547d0d58b76f0309e744f6184da78;p=portage.git Bug #336644 - Make EbuildIpcDaemon use AbstractPollTask._read_buf(), for better handling of errors like "IOError: [Errno 11] Resource temporarily unavailable". TODO: Apply a similar fix to ebuild-ipc.py. --- diff --git a/pym/_emerge/EbuildIpcDaemon.py b/pym/_emerge/EbuildIpcDaemon.py index 93333a6b1..f6bfecfbe 100644 --- a/pym/_emerge/EbuildIpcDaemon.py +++ b/pym/_emerge/EbuildIpcDaemon.py @@ -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