Runs the callback for the pipeline specified in the request.

    Raises:
      _CallbackTaskError if something was wrong with the request parameters.
502862
def run_callback(self):
    
    pipeline_id = self.request.get('pipeline_id')
    if not pipeline_id:
      raise _CallbackTaskError('"pipeline_id" parameter missing.')

    pipeline_key = db.Key.from_path(_PipelineRecord.kind(), pipeline_id)
    pipeline_record = db.get(pipeline_key)
    if pipeline_record is None:
      raise _CallbackTaskError(
          'Pipeline ID "%s" for callback does not exist.' % pipeline_id)

    params = pipeline_record.params
    real_class_path = params['class_path']
    try:
      pipeline_func_class = mr_util.for_name(real_class_path)
    except ImportError, e:
      raise _CallbackTaskError(
          'Cannot load class named "%s" for pipeline ID "%s".'
          % (real_class_path, pipeline_id))

    if 'HTTP_X_APPENGINE_TASKNAME' not in self.request.environ:
      if pipeline_func_class.public_callbacks:
        pass
      elif pipeline_func_class.admin_callbacks:
        if not users.is_current_user_admin():
          raise _CallbackTaskError(
              'Unauthorized callback for admin-only pipeline ID "%s"'
              % pipeline_id)
      else:
        raise _CallbackTaskError(
            'External callback for internal-only pipeline ID "%s"'
            % pipeline_id)

    kwargs = {}
    for key in self.request.arguments():
      if key != 'pipeline_id':
        kwargs[str(key)] = self.request.get(key)

    def perform_callback():
      stage = pipeline_func_class.from_id(pipeline_id)
      if stage is None:
        raise _CallbackTaskError(
            'Pipeline ID "%s" deleted during callback' % pipeline_id)
      return stage._callback_internal(kwargs)

    # callback_xg_transaction is a 3-valued setting (None=no trans,
    # False=1-eg-trans, True=xg-trans)
    if pipeline_func_class._callback_xg_transaction is not None:
      transaction_options = db.create_transaction_options(
          xg=pipeline_func_class._callback_xg_transaction)
      callback_result = db.run_in_transaction_options(transaction_options,
                                                      perform_callback)
    else:
      callback_result = perform_callback()

    if callback_result is not None:
      status_code, content_type, content = callback_result
      self.response.set_status(status_code)
      self.response.headers['Content-Type'] = content_type
      self.response.out.write(content)
1112158
public void run() {
        try {
            callback.open();
            this.request = getLogRequest(true);
            final HttpResponse response = client.execute(request);
            parseResponse(response);
        } catch (LogCallback.DoneException e) {
            // Signifies we're finished with the log stream.
        } catch (IOException e) {
            callback.error("IO Error while requesting logs: " + e + " " + Thread.currentThread().getName());
        } finally {
            callback.close();
        }
    }
427500
def _run_queued_callbacks(self):
        '''  '''
        for callback in self._queued_callbacks:
            try:
                callback()
            except Exception as ex:
                logger.error("Exception: %s" % str(ex))
704989
def run(self):
        
        while True:
            task = self.tasks_queue.get()
            if task is None:
                self.tasks_queue.task_done()
                break
            # No exception detected in any thread,
            # continue the execution.
            if self.exceptions_queue.empty():
                try:
                    # Execute the task
                    func, args, kargs = task
                    result = func(*args, **kargs)
                    self.results_queue.put(result)
                except Exception as e:
                    self.exceptions_queue.put(e)
            # Mark this task as done, whether an exception happened or not
            self.tasks_queue.task_done()
71277
def add_done_callback(self, callback):
        
        if self._done is None or self._done.is_set():
            raise ValueError('Task has already finished')
        if callable(callback):
            self.callbacks.append(callback)
803276
def start(self):
        
        if self.running:
            raise RuntimeError("client already running")

        self._main_task = asyncio.ensure_future(
            self._main(),
            loop=self._loop
        )
        self._main_task.add_done_callback(self._on_main_done)
763742
def _callback(self, bjobid, result, grade, problems, tests, custom, archive, stdout, stderr):
        
        self._jobs_done[str(bjobid)] = (result, grade, problems, tests, custom, archive, stdout, stderr)
        self._waiting_jobs.remove(str(bjobid))
719011
def _execute_callback(async, callback):
    
    from furious.async import Async

    if not callback:
        return async.result.payload

    if isinstance(callback, Async):
        return callback.start()

    return callback()
604493
def run(self, *args, **kwargs):
        
        if self._source is not None:
            return self._source.run(*args, **kwargs)
        else:
            self.queue(*args, **kwargs)
            return self.wait()
1152994
@Override
    public void run() {
        synchronized (this) {
            // Save current event pipeline and currently handled event
            // because a SynchronousEventPipeline can be called while
            // handling an event (from another event processor).
            InternalEventPipeline currentPipeline = FeedBackPipelineFilter
                .getAssociatedPipeline();
            EventBase<?> currentEvent = newEventsParent.get();
            try {
                super.run();
            } finally {
                newEventsParent.set(currentEvent);
                FeedBackPipelineFilter.setAssociatedPipeline(currentPipeline);
            }
        }
    }
498964
def run(self):
        ''''''
        while not self.wait(self.delay()):
            try:
                logger.info('Invoking callback %s', self.callback)
                self.callback()
            except StandardError:
                logger.exception('Callback failed')
440092
def callback(func):
    
    @functools.wraps(func)
    def wrapped(*args, **kwargs):
        result = func(*args, **kwargs)
        if inspect.iscoroutine(result):
            aio_loop.create_task(result)

    return wrapped
70227
def _start(self):
        
        try:
            self._polling_method.run()
        except Exception as err:
            self._exception = err

        finally:
            self._done.set()

        callbacks, self._callbacks = self._callbacks, []
        while callbacks:
            for call in callbacks:
                call(self._polling_method)
            callbacks, self._callbacks = self._callbacks, []
1373186
def run(self):
        
        while True:
            path, params = self.path_queue.get()
            errors = run(path, **params)
            self.result_queue.put(errors)
            self.path_queue.task_done()
468578
def execute(self, request, *args, **path_args):
        # type: (BaseHttpRequest, tuple, Dict[Any]) -> Any
        
        binding = self.binding
        if binding:
            # Provide binding as decorators are executed prior to binding
            return self.callback(binding, request, *args, **path_args)
        else:
            return self.callback(request, *args, **path_args)
437508
def request(self, *args, **kwargs):
        
        func = partial(super().request, *args, **kwargs)
        return self.loop.run_in_executor(self.thread_pool, func)
481920
def _run_callbacks(kind, *args) #:nodoc:
      options = args.last # Last callback arg MUST be a Hash

      send("_#{kind}").each do |callback, conditions|
        invalid = conditions.find do |key, value|
          value.is_a?(Array) ? !value.include?(options[key]) : (value != options[key])
        end

        callback.call(*args) unless invalid
      end
    end