CPU burst max running time - self.runtime_cfg.max_delay
545904
def command_max_delay(self, event=None):
        
        try:
            max_delay = self.max_delay_var.get()
        except ValueError:
            max_delay = self.runtime_cfg.max_delay

        if max_delay < 0:
            max_delay = self.runtime_cfg.max_delay

        if max_delay > 0.1:
            max_delay = self.runtime_cfg.max_delay

        self.runtime_cfg.max_delay = max_delay
        self.max_delay_var.set(self.runtime_cfg.max_delay)
1219656
def _is_timeout(self):
        '''  '''
        if self.cputime is None:
            is_cpulimit = False
        else:
            rlimits = self.runSet.benchmark.rlimits
            if SOFTTIMELIMIT in rlimits:
                limit = rlimits[SOFTTIMELIMIT]
            elif TIMELIMIT in rlimits:
                limit = rlimits[TIMELIMIT]
            else:
                limit = float('inf')
            is_cpulimit = self.cputime > limit

        if self.walltime is None:
            is_walllimit = False
        else:
            rlimits = self.runSet.benchmark.rlimits
            if WALLTIMELIMIT in rlimits:
                limit = rlimits[WALLTIMELIMIT]
            else:
                limit = float('inf')
            is_walllimit = self.walltime > limit

        return is_cpulimit or is_walllimit
749083
def configure(cls: typing.Type["ThreadPooled"], max_workers: typing.Optional[int] = None) -> None:
        
        if isinstance(cls.__executor, ThreadPoolExecutor):
            if cls.__executor.max_workers == max_workers:
                return
            cls.__executor.shutdown()

        cls.__executor = ThreadPoolExecutor(max_workers=max_workers)
519464
def _stop_by_max_time_mins(self):
        """"""
        if self.max_time_mins:
            total_mins_elapsed = (datetime.now() - self._start_datetime).total_seconds() / 60.
            if total_mins_elapsed >= self.max_time_mins:
                raise KeyboardInterrupt('{} minutes have elapsed. TPOT will close down.'.format(total_mins_elapsed))
241362
def delay(self, seconds=0, minutes=0, msg=None):
        
        delay_time = seconds + minutes * 60
        self._hw_manager.hardware.delay(delay_time)
588684
def run(self, timeout = 0):
        
        # same resolution as epoll
        ptimeout = int(
            timeout.days * 86400000 +
            timeout.microseconds / 1000 +
            timeout.seconds * 1000
            if timeout else (self.m_resolution if timeout is None else 0)
        )
        if self.tokens:
            scheduler = self.scheduler
            urgent = None
            # we use urgent as a optimisation: the last operation is returned
            #directly to the scheduler (the sched might just run it till it
            #goes to sleep) and not added in the sched.active queue
            while 1:
                try:
                    poverlapped = LPOVERLAPPED()
                    nbytes = DWORD()
                    completion_key = c_ulong()
                    #~ BOOL WINAPI GetQueuedCompletionStatus(
                      #~ __in   HANDLE CompletionPort,
                      #~ __out  LPDWORD lpNumberOfBytes,
                      #~ __out  PULONG_PTR lpCompletionKey,
                      #~ __out  LPOVERLAPPED *lpOverlapped,
                      #~ __in   DWORD dwMilliseconds
                    #~ );

                    rc = GetQueuedCompletionStatus(
                        self.iocp, # HANDLE CompletionPort
                        byref(nbytes), # LPDWORD lpNumberOfBytes
                        byref(completion_key), # PULONG_PTR lpCompletionKey
                        byref(poverlapped),
                        0 if urgent else ptimeout
                    )
                    overlap = poverlapped and poverlapped.contents
                    nbytes = nbytes.value
                except RuntimeError, e:
                    import warnings
                    warnings.warn("RuntimeError(%s) on GetQueuedCompletionStatus." % e)
                    # we will get "This overlapped object has lost all its
                    # references so was destroyed" when we remove a operation,
                    # it is garbage collected and the overlapped completes
                    # afterwards
                    break

                # well, this is a bit weird, if we get a aborted rc (via CancelIo
                #i suppose) evaluating the overlap crashes the interpeter
                #with a memory read error
                # also, we might get a "wait operation timed out", and no overlap pointer
                if rc != WSA_OPERATION_ABORTED and overlap:

                    if urgent:
                        op, coro = urgent
                        urgent = None
                        if op.prio & priority.OP:
                            # imediately run the asociated coroutine step
                            op, coro = scheduler.process_op(
                                coro.run_op(op, scheduler),
                                coro
                            )
                        if coro:
                            #TODO, what "op and "
                            if op and (op.prio & priority.CORO):
                                scheduler.active.appendleft( (op, coro) )
                            else:
                                scheduler.active.append( (op, coro) )
                    if overlap.object:
                        assert overlap.object in self.tokens
                        urgent = self.process_op(rc, nbytes, overlap)
                else:
                    #~ import warnings
                    #~ warnings.warn("rc=(%s: %s) overlap=(%s)" % (rc, ctypes.FormatError(rc), overlap))
                    break
            return urgent
        else:
            sleep(timeout)
1043916
private void handleRunAsync(RunAsync runAsync) {
		final long timeToRun = runAsync.getTimeNanos();
		final long delayNanos;

		if (timeToRun == 0 || (delayNanos = timeToRun - System.nanoTime()) <= 0) {
			// run immediately
			try {
				runAsync.getRunnable().run();
			} catch (Throwable t) {
				log.error("Caught exception while executing runnable in main thread.", t);
				ExceptionUtils.rethrowIfFatalErrorOrOOM(t);
			}
		}
		else {
			// schedule for later. send a new message after the delay, which will then be immediately executed
			FiniteDuration delay = new FiniteDuration(delayNanos, TimeUnit.NANOSECONDS);
			RunAsync message = new RunAsync(runAsync.getRunnable(), timeToRun);

			final Object envelopedSelfMessage = envelopeSelfMessage(message);

			getContext().system().scheduler().scheduleOnce(delay, getSelf(), envelopedSelfMessage,
					getContext().dispatcher(), ActorRef.noSender());
		}
	}
248235
def cpu_usage
      result = run("cgroup", "cpuacct.usage").to_s.strip
      result.empty? ? nil : Float("%.4f" % (result.to_i / 1E9))
    end
593921
def run0(self):
    
    if self.current:
      self.inactive = 0
      callback, args, kwds = self.current.popleft()
      _logging_debug('nowevent: %s', callback.__name__)
      callback(*args, **kwds)
      return 0
    if self.run_idle():
      return 0
    delay = None
    if self.queue:
      delay = self.queue[0][0] - self.clock.now()
      if delay <= 0:
        self.inactive = 0
        _, callback, args, kwds = self.queue.pop(0)
        _logging_debug('event: %s', callback.__name__)
        callback(*args, **kwds)
        # TODO: What if it raises an exception?
        return 0
    if self.rpcs:
      self.inactive = 0
      rpc = datastore_rpc.MultiRpc.wait_any(self.rpcs)
      if rpc is not None:
        _logging_debug('rpc: %s.%s', rpc.service, rpc.method)
        # Yes, wait_any() may return None even for a non-empty argument.
        # But no, it won't ever return an RPC not in its argument.
        if rpc not in self.rpcs:
          raise RuntimeError('rpc %r was not given to wait_any as a choice %r' %
                             (rpc, self.rpcs))
        callback, args, kwds = self.rpcs[rpc]
        del self.rpcs[rpc]
        if callback is not None:
          callback(*args, **kwds)
          # TODO: Again, what about exceptions?
      return 0
    return delay
1238628
def timelimit(timeout):
    """"""
    def _1(function):
        def _2(*args, **kw):
            class Dispatch(threading.Thread):
                def __init__(self):
                    threading.Thread.__init__(self)
                    self.result = None
                    self.error = None

                    self.setDaemon(True)
                    self.start()

                def run(self):
                    try:
                        self.result = function(*args, **kw)
                    except:
                        self.error = sys.exc_info()

            c = Dispatch()
            c.join(timeout)
            if c.isAlive():
                raise TimeoutError, 'took too long'
            if c.error:
                raise c.error[0], c.error[1]
            return c.result
        return _2
    return _1
1286493
def MaxSpeed(self, speed):
        '  '
        spi.SPI_write(self.CS, [0x07, 0x07])       # Max Speed setup 
        spi.SPI_write(self.CS, [0x00, 0x00])
        spi.SPI_write(self.CS, [speed, speed])
392649
def max_time_last
      max = 0
      i = 0
      while i < @children.size
        tl = @children[i].time_last
        max = tl if tl > max
        i += 1
      end
      max
    end
882243
def retry_mkstemp(suffix='', prefix='tmp', directory=None, max_retries=3):
    
    if directory is None:
        directory = current_app.config['CFG_TMPSHAREDDIR']
    for retry_count in range(1, max_retries + 1):
        try:
            tmp_file_fd, tmp_file_name = tempfile.mkstemp(suffix=suffix,
                                                          prefix=prefix,
                                                          dir=directory)
        except OSError as e:
            if e.errno == 19 and retry_count <= max_retries:
                # AFS Glitch?
                time.sleep(10)
            else:
                raise
        else:
            break
    return tmp_file_fd, tmp_file_name
607861
@Override public void runAppInBackground(Duration duration) {
        // timeout parameter is expected to be in milliseconds
        // float values are allowed
        execute(RUN_APP_IN_BACKGROUND,
                prepareArguments("seconds", prepareArguments("timeout", duration.toMillis())));
    }
19053
def cpu_throttling(self, cpu_throttling):
        

        log.info('QEMU VM "{name}" [{id}] has set the percentage of CPU allowed to {cpu}'.format(name=self._name,
                                                                                                 id=self._id,
                                                                                                 cpu=cpu_throttling))
        self._cpu_throttling = cpu_throttling
        self._stop_cpulimit()
        if cpu_throttling:
            self._set_cpu_throttling()
403515
private static void tryWaitingForGC() {
    // We could try to preallocate memory mx bean and count collections...
    // there is no guarantee it doesn't allocate stuff too though.
    final long timeout = System.currentTimeMillis() + 2000;
    while (System.currentTimeMillis() < timeout) {
      System.gc(); 
      try {
        Thread.sleep(250);
      } catch (InterruptedException e) {
        break;
      }
    }
  }
818227
async def _throttled_message(self, message):
        ''''''
        try:
            timeout = self.processing_timeout
            async with timeout_after(timeout):
                async with self._incoming_concurrency:
                    if self._cost_fraction:
                        await sleep(self._cost_fraction * self.cost_sleep)
                    await self.handle_message(message)
        except ProtocolError as e:
            self.logger.error(f'{e}')
            self._bump_errors(e)
        except TaskTimeout:
            self.logger.info(f'incoming request timed out after {timeout} secs')
            self._bump_errors()
        except ExcessiveSessionCostError:
            await self.close()
        except CancelledError:
            raise
        except Exception:
            self.logger.exception(f'exception handling {message}')
            self._bump_errors()