On Thu, Mar 31, 2011 at 10:29 AM, Iustin Pop <[email protected]> wrote:
> On Thu, Mar 31, 2011 at 10:25:59AM +0200, René Nussbaumer wrote:
>> There was a race condition on heavily loaded testsystem causing randomly
>> to fail the timeout unittests as the signal handler is not yet setup but
>> the timeout has already hit.
>>
>> Therefore we introduce a workaround to wait until a program reached a
>> certain point (for example after signal handling setup) before we
>> actually go for the real run. The wait of course has a timeout as well,
>> but it's pretty high. If we hit the 20 seconds we have really big issues
>> anyway.
>> ---
>>  lib/utils/process.py                  |   16 +++++++--
>>  test/ganeti.utils.process_unittest.py |   64 
>> +++++++++++++++++++++++++++++---
>>  2 files changed, 71 insertions(+), 9 deletions(-)
>
>> +class _PostforkProcessReadyHelper:
>> +  """A helper to use with _postfork_fn in RunCmd.
>> +
>> +  It makes sure a process has reached a certain state by reading from a 
>> fifo.
>> +
>> +  @ivar fifo_file: The fifo file created and checked by the helper
>> +
>> +  """
>> +  def __init__(self, fifo_dir, timeout):
>> +    """Initialize the helper.
>> +
>> +    @param fifo_dir: The dir where we can create the fifo
>> +    @param timeout: The time in seconds to wait before giving up
>> +
>> +    """
>> +    self.fifo_file = os.path.join(fifo_dir, "proccess_ready_%d" % 
>> time.time())
>> +    self.timeout = timeout
>> +    os.mkfifo(self.fifo_file)
>> +    self._fifo_fd = os.open(self.fifo_file, os.O_RDONLY | os.O_NONBLOCK)
>
> Why do you use a named pipe here instead of an anonymous one (pipe(2))?

Good point. Resent updated patch.

René

Reply via email to