def _InterruptibleDelay(self):
    """Delays but provides the mechanisms necessary to interrupt the delay as
    needed.

    """
    socket_wrapper = TestSocketWrapper()
    sock, path = socket_wrapper.Create()

    self.Log(constants.ELOG_DELAY_TEST, (path,))

    try:
      sock.settimeout(self.op.duration)
      start = time.time()
      (conn, _) = sock.accept()
    except socket.timeout, _:
      # If we timed out, all is well
      return False
    finally:
      # Destroys the original socket, but the new connection is still usable
      socket_wrapper.Destroy()

    try:
      # Change to remaining time
      time_to_go = (time.time() - start) - self.op.duration
      self.Log(constants.ELOG_MESSAGE,
               "Received connection, time to go is %d" % time_to_go)
      if time_to_go < 0:
        time_to_go = 0
      # pylint: disable=E1101
      # Instance of '_socketobject' has no ... member
      conn.settimeout(time_to_go)
      conn.recv(1)
      # pylint: enable=E1101
    except socket.timeout, _:
      # A second timeout can occur if no data is sent
      return False
    finally:
      conn.close()

    self.Log(constants.ELOG_MESSAGE,
             "Interrupted, time spent waiting: %d" % (time.time() - start))

    # Reaching this point means we were interrupted
    return True
dataset/ETHPy150Open ganeti/ganeti/lib/cmdlib/test.py/LUTestDelay._InterruptibleDelay/swapped operands of `-`