Run the actor loop
323272
def run
      while @running
        begin
          @timers.wait do |interval|
            interval = 0 if interval && interval < 0

            if message = @mailbox.check(interval)
              handle_message(message)

              break unless @running
            end
          end
        rescue MailboxShutdown
          @running = false
        rescue MailboxDead
          # TODO: not tests (but fails occasionally in tests)
          @running = false
        end
      end

      shutdown
    rescue ::Exception => ex
      handle_crash(ex)
      raise unless ex.is_a?(StandardError) || ex.is_a?(Celluloid::Interruption)
    end
171720
public void run () {
  //wait for finished item
  //send finished item to encoder
  //loop to top
  boolean loop = true;
  boolean interrupted = false;
  try {
    while(loop) {
      try {
        if(nextTarget == null)
          nextTarget = orderedEncodeRequests.poll(500,TimeUnit.MILLISECONDS);
        if(nextTarget == null) {
          loop = false;
        }
        else if(nextTarget.frameNumber < 0) {
          loop = false;
          nextTarget = null;
          orderedEncodeRequests.clear();
        }
        else if(finishedRequestStore.remove(nextTarget)) {
          encoder.blockFinished(nextTarget);
          nextTarget = null;
          synchronized(outstandingCountLock) {
            outstandingCount--;
            outstandingCountLock.notifyAll();
          }
        }
        else {
          BlockEncodeRequest ber = finishedEncodeRequests.poll(500, TimeUnit.MILLISECONDS);
          if(ber == null) {//nothing to process yet, let this thread end.
            loop = false;
          }
          else if(nextTarget == ber) {
            encoder.blockFinished(ber);
            nextTarget = null;
            synchronized(outstandingCountLock) {
              outstandingCount--;
              outstandingCountLock.notifyAll();
            }
          }
          else {
            finishedRequestStore.add(ber);
          }
        }
        }catch(InterruptedException e) {
          interrupted = true;
        }
      }
    }finally {
      if(interrupted)
      Thread.currentThread().interrupt();
    }
    synchronized(this) {
      managerThread = null;
      restartManager();
    }
  }
1166943
def run(self, context: ActionContext):
        
        iterator = itertools.count(start=self.start, step=self.step)
        for i in iterator:
            self.with_iteration(i)
            if self.stop is not None and i >= self.stop:
                break
            try:
                self._action(context)
            except Loop.Continue:
                continue
            except Loop.Break:
                break
272966
async def main(loop):
    """"""
    pyvlx = PyVLX('pyvlx.yaml', loop=loop)
    # Alternative:
    # pyvlx = PyVLX(host="192.168.2.127", password="velux123", loop=loop)

    # Runing scenes:
    await pyvlx.load_scenes()
    await pyvlx.scenes["All Windows Closed"].run()

    # Changing position of windows:
    await pyvlx.load_nodes()
    await pyvlx.nodes['Bath'].open()
    await pyvlx.nodes['Bath'].close()
    await pyvlx.nodes['Bath'].set_position(Position(position_percent=45))

    # Changing of on-off switches:
    # await pyvlx.nodes['CoffeeMaker'].set_on()
    # await pyvlx.nodes['CoffeeMaker'].set_off()

    # You can easily rename nodes:
    # await pyvlx.nodes["Window 10"].rename("Window 11")

    await pyvlx.disconnect()
750173
def run_loop(leds=all_leds):
    
    print('Loop started.\nPress Ctrl+C to break out of the loop.')
    while 1:
        try:
            if switch():
                [led.on() for led in leds]
            else:
                [led.off() for led in leds]
        except OSError: # VCPInterrupt # Ctrl+C in interpreter mode.
            break
431281
def run(self):
        '''
        
        '''
        salt.utils.process.appendproctitle(self.__class__.__name__)
        self.event = get_event('master', opts=self.opts, listen=True)
        events = self.event.iter_events(full=True)
        self.event.fire_event({}, 'salt/event_listen/start')
        try:
            for event in events:
                if event['tag'] == 'salt/event/exit':
                    self.stop = True
                if self._filter(event):
                    self.event_queue.append(event)
                if len(self.event_queue) >= self.event_return_queue:
                    self.flush_events()
                if self.stop:
                    break
        finally:  # flush all we have at this moment
            if self.event_queue:
                self.flush_events()
49779
def run(self):
        
        Global.LOGGER.debug(f"action {self.name} is running")

        for tmp_monitored_input in self.monitored_input:
            sender = "*" + tmp_monitored_input + "*"
            Global.LOGGER.debug(f"action {self.name} is monitoring {sender}")

        while self.is_running:
            try:
                time.sleep(Global.CONFIG_MANAGER.sleep_interval)
                self.on_cycle()

            except Exception as exc:
                Global.LOGGER.error(f"error while running the action {self.name}: {str(exc)}")
782304
def run_as_coroutine(self, stdin, callbacks):
        
        # Note: We cannot use "yield from", because this package also
        #       installs on Python 2.
        assert isinstance(callbacks, EventLoopCallbacks)

        if self.closed:
            raise Exception('Event loop already closed.')

        timeout = AsyncioTimeout(INPUT_TIMEOUT, callbacks.input_timeout, self.loop)
        self.running = True

        try:
            while self.running:
                timeout.reset()

                # Get keys
                try:
                    g = iter(self.loop.run_in_executor(None, self._console_input_reader.read))
                    while True:
                        yield next(g)
                except StopIteration as e:
                    keys = e.args[0]

                # Feed keys to input processor.
                for k in keys:
                    callbacks.feed_key(k)
        finally:
            timeout.stop()
129449
def run_step(self):
        """"""
        rewriter = StreamRewriter(self.context.iter_formatted_strings)
        super().run_step(rewriter)
267010
def run(entry_point, drivers, loop = None):
    ''' 
    '''
    program = setup(entry_point, drivers)
    dispose = program.run()
    if loop == None:
        loop = asyncio.get_event_loop()

    loop.run_forever()
    dispose()
1025060
def do_run(self, arg):
        '''  '''
        if not self.arm.is_connected():
            print(self.style.error('Error: ', 'Arm is not connected.'))
            return

        # Load the script.
        try:
            with open(arg) as f:
                lines = [line.strip() for line in f.readlines()]
        except IOError:
            print(self.style.error('Error: ',
                                   'Could not load file \'{}\'.'.format(arg)))
            return

        for line in lines:
            if self.wrapper:
                line = self.wrapper.wrap_input(line)
            self.arm.write(line)
            res = self.arm.read()
            if self.wrapper:
                res = self.wrapper.wrap_output(res)
            print(res)
1167296
def do(actor, targets)
    return if targets.empty?
    #If next item is a collection of prototypes, copy them all in at once.
    if prototypes[@prototype_index].respond_to?(:each)
      prototypes[@prototype_index].each do |prototype|
        actor.environment.add_object(generate_child(actor, prototype, targets[@target_index]))
      end
    #Otherwise copy the single prototype.
    else
      targets[@target_index].environment.add_object(generate_child(actor, prototypes[@prototype_index], targets[@target_index]))
    end
    #Move to next target and prototype group, wrapping to start of array if need be.
    @target_index = (@target_index + 1) % targets.length
    @prototype_index = (@prototype_index + 1) % prototypes.length
  end
1266780
def run(self):
        '''
        
        '''
        import salt.key
        self.parse_args()

        self.setup_logfile_logger()
        verify_log(self.config)

        key = salt.key.KeyCLI(self.config)
        if check_user(self.config['user']):
            key.run()
174250
def do_execute(self):
        

        result = None
        self._stopped = False
        self._stopping = False

        for actor in self.owner.actors:
            if self.is_stopping() or self.is_stopped():
                break
            actor.input = self.owner.input
            result = actor.execute()
            if result is not None:
                break

        return result
1216493
def Run(self):
        ""
        inputs = self.GetInput()
        return SendInput(
            len(inputs),
            ctypes.byref(inputs),
            ctypes.sizeof(INPUT))
574050
def run(self, n_iter=-1, bg=False):
        
        if n_iter == -1:
            if not self.eval_at:
                raise ValueError('Set n_iter or define evaluate_at.')

            n_iter = self.eval_at[-1] + 1

        self._running.set()

        if bg:
            self._t = threading.Thread(target=lambda: self._run(n_iter))
            self._t.start()
        else:
            self._run(n_iter)
1229218
def run(self):
        """"""
        # Create the thread pool.
        executor = concurrent.futures.ThreadPoolExecutor(
            max_workers=self._config['num_workers'])

        # Wait to ensure multiple senders can be synchronised.
        now = int(datetime.datetime.utcnow().timestamp())
        start_time = ((now + 29) // 30) * 30
        self._log.info('Waiting until {}'.format(
                       datetime.datetime.fromtimestamp(start_time)))
        while int(datetime.datetime.utcnow().timestamp()) < start_time:
            time.sleep(0.1)

        # Run the event loop.
        loop = asyncio.get_event_loop()
        try:
            loop.run_until_complete(self._run_loop(executor))
        except KeyboardInterrupt:
            pass
        finally:
            # Send the end of stream message to each stream.
            self._log.info('Shutting down, closing streams...')
            tasks = []
            for stream, item_group in self._streams:
                tasks.append(stream.async_send_heap(item_group.get_end()))
            loop.run_until_complete(asyncio.gather(*tasks))
            self._log.info('... finished.')
            executor.shutdown()