Use blocking IO in ebuild-ipc.py and EbuildIpcDaemon._send_reply(),
authorZac Medico <zmedico@gentoo.org>
Sat, 18 Sep 2010 11:58:40 +0000 (04:58 -0700)
committerZac Medico <zmedico@gentoo.org>
Sat, 18 Sep 2010 11:58:40 +0000 (04:58 -0700)
in hopes that it will be more portable (see bug #337465).

bin/ebuild-ipc.py
pym/_emerge/EbuildIpcDaemon.py

index 2d524a75267be26df101e0ee9eaa8a4e72b0dd51..7637fb5d55d24cccadaa545e2663aad4d17baab9 100755 (executable)
@@ -9,7 +9,6 @@ import array
 import logging
 import os
 import pickle
-import select
 import signal
 import sys
 import time
@@ -91,9 +90,6 @@ class EbuildIpc(object):
 
                # File streams are in unbuffered mode since we do atomic
                # read and write of whole pickles.
-               input_fd = os.open(self.ipc_out_fifo,
-                       os.O_RDONLY|os.O_NONBLOCK)
-               input_file = os.fdopen(input_fd, 'rb', 0)
                output_file = None
 
                while True:
@@ -124,19 +120,7 @@ class EbuildIpc(object):
                                        self._no_daemon_msg()
                                        return 2
 
-               start_time = time.time()
-               while True:
-                       events = select.select([input_file], [], [],
-                               self._COMMUNICATE_RETRY_TIMEOUT_SECONDS)
-                       if events[0]:
-                               break
-                       else:
-                               if self._daemon_is_alive():
-                                       self._timeout_retry_msg(start_time,
-                                               portage.localization._('during select'))
-                               else:
-                                       self._no_daemon_msg()
-                                       return 2
+               input_file = open(self.ipc_out_fifo, 'rb', 0)
 
                start_time = time.time()
                while True:
index 66d868ba2bb3d1deffecb1ef111a77c48f490c07..73a088c5e775000b007b207f1a6f80f198a9d8a4 100644 (file)
@@ -3,9 +3,7 @@
 
 import errno
 import pickle
-from portage import os
 from _emerge.FifoIpcDaemon import FifoIpcDaemon
-from _emerge.PollConstants import PollConstants
 
 class EbuildIpcDaemon(FifoIpcDaemon):
        """
@@ -67,15 +65,12 @@ class EbuildIpcDaemon(FifoIpcDaemon):
                                        reply_hook()
 
        def _send_reply(self, reply):
-               output_fd = os.open(self.output_fifo, os.O_WRONLY|os.O_NONBLOCK)
-
                # File streams are in unbuffered mode since we do atomic
                # read and write of whole pickles.
-               output_file = os.fdopen(output_fd, 'wb', 0)
+               output_file = open(self.output_fifo, 'wb', 0)
 
                # Write the whole pickle in a single atomic write() call,
                # since the reader is in non-blocking mode and we want
                # it to get the whole pickle at once.
                output_file.write(pickle.dumps(reply))
-               output_file.flush()
                output_file.close()