Stops iterating before yielding the specified idx.
515207
def stop_at(iterable, idx):
    """"""
    for i, item in enumerate(iterable):
        if i == idx: return
        yield item
1370564
public synchronized void cancel() // d583637
    {
        ivIsCanceled = true;
        stopAlarm();

        // F743-33394 - Wait for the sweep to finish.
        while (ivIsRunning) {
            try {
                wait();
            } catch (InterruptedException ex) {
                if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled())
                    Tr.debug(tc, "interrupted", ex);
                Thread.currentThread().interrupt();
            }
        }

        ivActivator = null;
    }
1243465
def take_until_including(condition):
    
    def take_until_including_(interable):
        for i in interable:
            if not condition(i):
                yield i
            else:
                yield i
                break
    return take_until_including_
929497
def pop_state(self, idx=None):
        

        self.state.pop()

        if idx is not None:
            self.str_begin = idx
1057330
def iter(self, start=0, count=1000):
        
        cursor = '0'
        _loads = self._loads
        stop = start + count
        while cursor:
            cursor = self._client.lrange(self.key_prefix, start, stop)
            for x in cursor or []:
                yield _loads(x)
            start += (count + 1)
            stop += (count + 1)
595628
def stop():
  '''  '''

  output, err = cli_syncthing_adapter.sys(exit=True)
  click.echo("%s" % output, err=err)
1075519
private void waitForMoveCompletion() {
    boolean shouldWait;
    int waitedIterations = 0;
    do {
      shouldWait = false;
      for (BalancerDatanode target : plan.targets) {
        if (!target.isPendingQEmpty()) {
          shouldWait = true;
        }
      }
      if (shouldWait) {
        try {
          if (waitedIterations > MAX_WAIT_ITERATIONS) {
            for (BalancerDatanode target : plan.targets) {
              target.killPending();
            }
            continue;
          }
          waitedIterations++;
          Thread.sleep(blockMoveWaitTime);
        } catch (InterruptedException ignored) {
        }
      }
    } while (shouldWait);
  }
501276
function stopOnProcess(index) {
  log( 'Attempting to stop ' + index + '...' );

  done = this.async();
  findProcessWithIndex( index, function(process) {
    if( typeof process !== 'undefined' ) {
      log( forever.format(true,[process]) );

      forever.stop( index )
        .on('stop', function() {
          done();
        })
        .on('error', function(message) {
          error( 'Error stopping ' + index + '. [REASON] :: ' + message );
          done(false);
        });
    }
    else {
      gruntRef.warn( index + ' not found in list of processes in forever.' );
      done();
    }
  });
}
1229367
@FFDCIgnore(InterruptedException.class)
    private boolean waitForIndex(int index) {
        final String methodName = "waitForIndex(): ";
        while (!!!tryToFetchElement(index)) {
            try {
                if (stateLock.hasTimedOut()) {
                    markTimedOut();
                    if (tc.isDebugEnabled())
                        Tr.debug(tc, methodName + "TIMED OUT!");
                    return false;
                }
                if (tc.isDebugEnabled())
                    Tr.debug(tc, methodName + "waiting ...");
                boolean result = stateLock.waitForEvent();
                if (tc.isDebugEnabled())
                    Tr.debug(tc, methodName + "waitForEvent result is [" + result + "] will Loop again to check timeout");
            } catch (InterruptedException ignored) {
                // NO FFDC
                if (tc.isDebugEnabled())
                    Tr.debug(tc, methodName + "interrupted");
            }
        }
        return true;
    }
1017804
private void stopContainerQuietly(final String image, final String idOrName) {
        final long startTime = System.currentTimeMillis();
        try {
            LOGGER.info("Killing docker container {} with id {}", image, idOrName);
            final int secondsToWaitBeforeKilling = 10;
            client.stopContainer(containerId, secondsToWaitBeforeKilling);
        } catch (DockerException | InterruptedException e) {
            // log error and ignore exception
            LOGGER.warn("Unable to kill docker container {} with id", image, idOrName, e);
        } finally {
            final long elapsedMillis = System.currentTimeMillis() - startTime;
            LOGGER.info("Docker container {} with id {} killed in {}ms", image, idOrName, elapsedMillis);
        }
    }
191655
def stop(self):
        """"""
        et = ET.ElementTree(self.checkstyle_element)
        f = BytesIO()
        et.write(f, encoding='utf-8', xml_declaration=True)
        xml = f.getvalue().decode('utf-8')
        if self.output_fd is None:
            print(xml)
        else:
            self.output_fd.write(xml)
        super(CheckstylePlugin, self).stop()
336512
def _stop_instance(self):
        """"""
        instance = self._get_instance()
        instance.stop()
        self._wait_on_instance('stopped', self.timeout)
1209164
def stop(self, reason=None):
        """"""
        self.logger.info('stopping')
        self.loop.stop(pyev.EVBREAK_ALL)
752948
public void stopping() {
        boolean isTraceOn = TraceComponent.isAnyTracingEnabled();
        if (isTraceOn && tc.isDebugEnabled())
            Tr.debug(tc, "stopping");

        J2EEName j2eeName = ivApplicationMetaData == null ? null : ivApplicationMetaData.getJ2EEName();
        beginStopping(true, j2eeName, ivModules); // F743-26072
    }
729864
private void waitUntilFlowPreparationFinish() throws InterruptedException {
    final Duration SLEEP_INTERVAL = Duration.ofSeconds(5);
    while (this.preparingFlowCount.intValue() != 0) {
      logger.info(this.preparingFlowCount + " flow(s) is/are still being setup before complete "
          + "deactivation.");
      Thread.sleep(SLEEP_INTERVAL.toMillis());
    }
  }
437645
@Override
    public void write(int idx) throws IOException {
        try {
            beforeWrite(1);
            out.write(idx);
            afterWrite(1);
        } catch (IOException e) {
            handleIOException(e);
        }
    }
1330411
def stop(self):
        
        if not self.is_running():
            raise RuntimeError('Not started')
        running, self._running = self._running, None
        try:
            next(running)
        except StopIteration:
            # expected.
            pass
        else:
            raise TypeError('run() must yield just one time')