Invoke the lifecycle methods for a message
        (prepare, process, on_finish), yielding if any are coroutines.
541012
def _execute(self):
        
        for call in (self.prepare, self.process, self.on_finish):
            self.logger.debug('Invoking %r', call)
            result = call()
            if concurrent.is_future(result):
                yield result
1231039
def call(message, captures, arguments)
      bargs = captures + arguments

      thread = Thread.new {
        @bot.loggers.debug "[New thread] For #{self}: #{Thread.current} -- #{@thread_group.list.size} in total."

        begin
          if @execute_in_callback
            @bot.callback.instance_exec(message, *@args, *bargs, &@block)
          else
            @block.call(message, *@args, *bargs)
          end
        rescue => e
          @bot.loggers.exception(e)
        ensure
          @bot.loggers.debug "[Thread done] For #{self}: #{Thread.current} -- #{@thread_group.list.size - 1} remaining."
        end
      }

      @thread_group.add(thread)
      thread
    end
148606
def process_message(self, message):
        
        try:
            self.logger.debug("Received message %s with id %r.", message, message.message_id)
            self.broker.emit_before("process_message", message)

            res = None
            if not message.failed:
                actor = self.broker.get_actor(message.actor_name)
                res = actor(*message.args, **message.kwargs)

            self.broker.emit_after("process_message", message, result=res)

        except SkipMessage:
            self.logger.warning("Message %s was skipped.", message)
            self.broker.emit_after("skip_message", message)

        except BaseException as e:
            # Stuff the exception into the message [proxy] so that it
            # may be used by the stub broker to provide a nicer
            # testing experience.
            message.stuff_exception(e)

            if isinstance(e, RateLimitExceeded):
                self.logger.warning("Rate limit exceeded in message %s: %s.", message, e)
            else:
                self.logger.warning("Failed to process message %s with unhandled exception.", message, exc_info=True)

            self.broker.emit_after("process_message", message, exception=e)

        finally:
            # NOTE: There is no race here as any message that was
            # processed must have come off of a consumer.  Therefore,
            # there has to be a consumer for that message's queue so
            # this is safe.  Probably.
            self.consumers[message.queue_name].post_process_message(message)
            self.work_queue.task_done()
384058
def on_message(self, message):
        
        self._record_activity()
        if hasattr(self, 'ws'):
            self.ws.write_message(message, binary=isinstance(message, bytes))
1257845
def call(self, method, args={}, retry=False, retry_policy=None,
             ticket=None, **props):
        """"""
        ticket = ticket or uuid()
        reply_q = self.get_reply_queue(ticket)
        self.cast(method, args, declare=[reply_q], reply_to=ticket, **props)
        return self.AsyncResult(ticket, self)
866926
function done(context, err, message) {
    if (err) return fail(context, err);
    if (typeof message !== "undefined") shell.write(message);
    context.end();
}
145160
def on_message(self, handler, msg):
        
        if self.remote_debugging:
            #: Forward to other clients
            for h in self.handlers:
                if h != handler:
                    h.write_message(msg, True)
        else:
            print(msg)
711417
def await_message(self, *args, **kwargs) -> 'asyncio.Future[Message]':
        
        fut = asyncio.Future()
        @self.on_message(*args, **kwargs)
        async def handler(message):
            fut.set_result(message)
        # remove handler when done or cancelled
        fut.add_done_callback(lambda _: self.remove_message_handler(handler))
        return fut
328318
@Transactional
	public void processMessage(ProcessInstance processInstance,
			Message<?> message, MessageMapper messageMapper) {
		Object context = getContextDAO().getContext(processInstance.getObjectInstance());
		processInstance.setStatus(TaskStatus.GO);
		try {
			messageMapper.unpackMessage(message, context);
		} catch (Exception e) {
			processInstance.setStatus(TaskStatus.ABORTING);
			processInstance.setComment(e.getMessage());
		}
		log.debug("set status to processInstance {} to {} {}",processInstance.getId(),processInstance.getStatus(),context);
		getContextDAO().mergeContext(context);
		getWorkflowDAO().mergeProcessInstance(processInstance);
		getWorkflowDAO().flush();
		if (log.isDebugEnabled()) {
			getWorkflowDAO().getActiveProcesses();
		}
	}
432749
def process(method_name, *args) #:nodoc:
      payload = {
        carrier: self.class.name,
        action: method_name
      }

      ActiveSupport::Notifications.instrument("process.sms_carrier", payload) do
        super
        @_message = NullMessage.new unless @_sms_was_called
      end
    end
453463
def coroutine(func):
    '''
    
    '''
    def start(*args, **kwargs):
        cr = func(*args, **kwargs)
        cr.next()
        return cr
    return start
117510
def run(self):
        ''''''
        # We left-append rather than emit (right-append) because some message
        # may have been already queued for execution before the director runs.
        global_event_queue.appendleft((INITIATE, self, (), {}))
        while global_event_queue:
            self.process_event(global_event_queue.popleft())
226576
def on_message(self, message):
        
        log.debug('Got websocket message %s', message)
        if message == 'websocket client ready':
            if self.connected:
                # TBD: Add ability to run commands in this branch
                log.debug('Websocket already connected, returning')
                return

            self.connected = True

            while True:
                try:
                    event = yield self.application.event_listener.get_event(self)
                    self.write_message(
                        salt.utils.json.dumps(event, _json_module=_json))
                except Exception as err:
                    log.info('Error! Ending server side websocket connection. Reason = %s', err)
                    break

            self.close()
        else:
            # TBD: Add logic to run salt commands here
            pass
501484
public void processMessage (Message msg)
    {
        if (_client.getRunQueue().isRunning()) {
            // append it to our queue
            _actions.append(msg);
            // and queue ourselves up to be run
            _client.getRunQueue().postRunnable(this);
        } else {
            log.info("Dropping message as RunQueue is shutdown", "msg", msg);
        }
    }
1098233
private <I extends Message, O extends Message> ListenableFuture<JsonRpcResponse> invoke(
      ServerMethod<I, O> method, JsonObject parameter, JsonElement id) {
    I request;
    try {
      request = (I) Messages.fromJson(method.inputBuilder(), parameter);
    } catch (Exception e) {
      serverLogger.logServerFailure(method, e);
      SettableFuture<JsonRpcResponse> future = SettableFuture.create();
      future.setException(e);
      return future;
    }
    ListenableFuture<O> response = method.invoke(request);
    return Futures.transform(response, new JsonConverter(id), TRANSFORM_EXECUTOR);
  }
214991
def dispatch(self, message):
        

        for validator, callback in self.validators:
            if not validator.matches(message):
                continue

            callback(message)
            return

        raise ArgumentError("No handler was registered for message", message=message)
526427
public static void invoke() {
        for (final Runnable instance : instances) {
            try {
                instance.run();
            } catch (final Throwable t) {
                LOGGER.error(SHUTDOWN_HOOK_MARKER, "Caught exception executing shutdown hook {}", instance, t);
            }
        }
    }