Copy paste job from `SimpleExecutor.stop()` to add the `timeout` parameter.
426492
def stop(self, sig=None, timeout=10):
        
        if self.process is None:
            return self

        if sig is None:
            sig = self._sig_stop

        try:
            os.killpg(self.process.pid, sig)
        except OSError as err:
            if err.errno in IGNORED_ERROR_CODES:
                pass
            else:
                raise

        def process_stopped():
            """Return True only only when self.process is not running."""
            return self.running() is False

        self._set_timeout(timeout)
        try:
            self.wait_for(process_stopped)
        except TimeoutExpired:
            log.warning('Timeout expired, killing process', process=self)
            pass

        self._kill_all_kids(sig)
        self._clear_process()
        return self
197816
public final <T> boolean replace(String key, final int exp, final T value,
      final Transcoder<T> transcoder, final long timeout)
      throws TimeoutException, InterruptedException, MemcachedException {
    key = this.preProcessKey(key);
    byte[] keyBytes = this.checkStoreArguments(key, exp, value);
    return this.sendStoreCommand(
        this.commandFactory.createReplaceCommand(key, keyBytes, exp, value, false, transcoder),
        timeout);
  }
320784
def queue_put_stoppable(self, q, obj):
        
        while not self.stopped():
            try:
                q.put(obj, timeout=5)
                break
            except queue.Full:
                pass
309285
private Object doOp(Op op) throws TimeoutException {
        try {
            if (op.txn != null)
                op.txn.add(op);
            Object result = runOp(op);
            if (result == PENDING)
                return op.getResult(timeout, TimeUnit.MILLISECONDS);
            else if (result == null && op.isCancelled())
                throw new CancellationException();
            else
                return result;
        } catch (java.util.concurrent.TimeoutException e) {
            throw new TimeoutException(e);
        } catch (InterruptedException e) {
            return null;
        } catch (ExecutionException e) {
            Throwable ex = e.getCause();
            if (ex instanceof TimeoutException)
                throw (TimeoutException) ex;
            Throwables.propagateIfPossible(ex);
            throw Throwables.propagate(ex);
        }
    }
999457
async def timeout(source, timeout):
    
    async with streamcontext(source) as streamer:
        while True:
            try:
                item = await wait_for(anext(streamer), timeout)
            except StopAsyncIteration:
                break
            else:
                yield item
1296681
def stop_process(self, process, timeout=None):
        

        process["terminate"] = True
        if timeout is not None:
            process["terminate_at"] = time.time() + timeout
        process["subprocess"].send_signal(signal.SIGINT)
1092748
private void timeoutHasExpired(final Timeout timeout, final TimeoutExpirationContext context) {
        try {
            addMessage(timeout, context.getOriginalHeaders());
        } catch (Exception ex) {
            LOG.error("Error handling timeout {}", timeout, ex);
        }
    }
218109
function printTimingAndExit(startTime) {
  const execTime = time() - startTime;

  printColumns(chalk.green(`Finished in: ${execTime.toFixed()}ms`));
  process.exit(0);
}
5363
def brpoplpush(self, sourcekey, destkey, timeout=0, encoding=_NOTSET):
        
        if not isinstance(timeout, int):
            raise TypeError("timeout argument must be int")
        if timeout < 0:
            raise ValueError("timeout must be greater equal 0")
        return self.execute(b'BRPOPLPUSH', sourcekey, destkey, timeout,
                            encoding=encoding)
18000
function stopTimeout(ctx) {
  assert(ctx);
  if (ctx.timer != null) {
    clearTimeout(ctx.timer);
    ctx.timer = null;
  }
  ctx.stopped = true;
}
996122
protected static CommandExecutor create(int timeout, String param) {
        String[] params = param.split(" ");
        CommandExecutor processModel = null;
        synchronized (PRC) {
            try {
                Process process = PRC.command(params)
                        .redirectErrorStream(true)
                        .start();
                processModel = new CommandExecutor(process, timeout);
                // Sleep 10 to create next
                try {
                    Thread.sleep(10);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            } catch (IOException e) {
                e.printStackTrace();
            }
        }

        return processModel;
    }
882844
def stop(self, timeout=None):
        
        with self._lock:
            if self._thread:
                self._queue.put_nowait(self._terminator)
                self._thread.join(timeout=timeout)
                self._thread = None
                self._thread_for_pid = None
1048177
@Override
	public void rejectedExecution(Runnable r, ThreadPoolExecutor executor) {
		int counts = rejectCounts.incrementAndGet();
		if(logger.isWarnEnabled()) {
			int t = counts % 100;
			if (t == 0) {
					logger.warn(new StringBuilder().append("Task[").append(message).append("] blocked ").append(counts).append(" times.").toString());
			}
		}
//
		try {
			if(sliceScrollBlockedWaitTimeout <= 0) {
				executor.getQueue().put(r);
			}
			else {
				boolean result = executor.getQueue().offer(r, this.sliceScrollBlockedWaitTimeout, TimeUnit.MILLISECONDS);
				if(!result){
					throw new RejectedExecutionException(new StringBuilder().append("Task[").append(message).append("] rejected: wait timeout after ")
							.append(sliceScrollBlockedWaitTimeout).append(" MILLISECONDS.").toString());
				}
			}
		} catch (InterruptedException e1) {
			throw new RejectedExecutionException(e1);
		}
	}
819440
@Override
    public synchronized Task take() throws TimeoutException {
        try {
            Task task = queue.remove();
            inprocess.add(task);
            return task;
        } catch (NoSuchElementException ex) {
            throw new TimeoutException(ex);
        }
    }
219254
async def spaceout(source, interval):
    
    timeout = 0
    loop = asyncio.get_event_loop()
    async with streamcontext(source) as streamer:
        async for item in streamer:
            delta = timeout - loop.time()
            delay = delta if delta > 0 else 0
            await asyncio.sleep(delay)
            yield item
            timeout = loop.time() + interval
893941
def stop(self, timeout=5):
        
        # Must shut down threads here so the code that calls
        # this method can know when all threads are stopped.
        for worker in self._threads:
            self._queue.put(_SHUTDOWNREQUEST)

        # Don't join currentThread (when stop is called inside a request).
        current = threading.currentThread()
        if timeout is not None and timeout >= 0:
            endtime = time.time() + timeout
        while self._threads:
            worker = self._threads.pop()
            if worker is not current and worker.isAlive():
                try:
                    if timeout is None or timeout < 0:
                        worker.join()
                    else:
                        remaining_time = endtime - time.time()
                        if remaining_time > 0:
                            worker.join(remaining_time)
                        if worker.isAlive():
                            # We exhausted the timeout.
                            # Forcibly shut down the socket.
                            c = worker.conn
                            if c and not c.rfile.closed:
                                try:
                                    c.socket.shutdown(socket.SHUT_RD)
                                except TypeError:
                                    # pyOpenSSL sockets don't take an arg
                                    c.socket.shutdown()
                            worker.join()
                except (
                    AssertionError,
                    # Ignore repeated Ctrl-C.
                    # See
                    # https://github.com/cherrypy/cherrypy/issues/691.
                    KeyboardInterrupt,
                ):
                    pass
125890
async def shutdown(self, timeout: Optional[float]=15.0) -> None:
        """"""
        self._force_close = True

        if self._keepalive_handle is not None:
            self._keepalive_handle.cancel()

        if self._waiter:
            self._waiter.cancel()

        # wait for handlers
        with suppress(asyncio.CancelledError, asyncio.TimeoutError):
            with CeilTimeout(timeout, loop=self._loop):
                if (self._error_handler is not None and
                        not self._error_handler.done()):
                    await self._error_handler

                if (self._task_handler is not None and
                        not self._task_handler.done()):
                    await self._task_handler

        # force-close non-idle handler
        if self._task_handler is not None:
            self._task_handler.cancel()

        if self.transport is not None:
            self.transport.close()
            self.transport = None