Blocking until the task finish and return the callback_result.until
977184
def callback_result(self):
        """"""
        if self._state == self._PENDING:
            self._loop.run_until_complete(self)
        if self._callbacks:
            result = self._callback_result
        else:
            result = self.result()
        return result
1095716
async def block_until(*conditions, timeout=None, wait_period=0.5, loop=None):
    
    async def _block():
        while not all(c() for c in conditions):
            await asyncio.sleep(wait_period, loop=loop)
    await asyncio.wait_for(_block(), timeout, loop=loop)
105075
def wait(self):
        """"""
        self._returncode = self.process.wait()
        try:
            self.process.stderr.close()
        except:
            pass
        self.set_status(self.S_DONE, "status set to Done")

        return self._returncode
302955
def catch_result(task_func):
    

    @functools.wraps(task_func, assigned=available_attrs(task_func))
    def dec(*args, **kwargs):
        # inicialize
        orig_stdout = sys.stdout
        sys.stdout = content = StringIO()
        task_response = task_func(*args, **kwargs)
        # catch
        sys.stdout = orig_stdout
        content.seek(0)
        # propagate to the response
        task_response['stdout'] = content.read()
        return task_response
    return dec
1011019
def blocking(func, *args, **kwargs):
    
    pool = get_io_pool()
    fut = pool.submit(func, *args, **kwargs)
    return fut.result()
1032598
def done(self, result, noraise=False):
        
        # [??] Should this be in a critical section?

        # Has done() already been called on this task?
        if self.ev_done.is_set():
            # ??
            if isinstance(self.result, Exception) and (not noraise):
                raise self.result
            return self.result

        # calculate running time and other finalization
        self.endtime = time.time()
        try:
            self.totaltime = self.endtime - self.starttime
        except AttributeError:
            # task was not initialized properly
            self.totaltime = 0.0
        self.result = result

        # Release thread waiters
        self.ev_done.set()

        # Perform callbacks for event-style waiters
        self.make_callback('resolved', self.result)

        # If the result is an exception, then our final act is to raise
        # it in the caller, unless the caller explicitly supressed that
        if isinstance(result, Exception) and (not noraise):
            raise result

        return result
692873
def sleep(self, delay):
        
        d = Deferred()
        self._get_loop().callLater(delay, d.callback, None)
        return d
1230304
def wait(self):
        
        try:
            SpawningProxy(self.containers, abort_on_error=True).wait()
        except Exception:
            # If a single container failed, stop its peers and re-raise the
            # exception
            self.stop()
            raise
1331999
def result(self):
        
        # Send None to all threads to cleanly stop them
        for _ in range(self.num_threads):
            self.tasks_queue.put(None)
        # Wait for completion of all the tasks in the queue
        self.tasks_queue.join()
        # Check if one of the thread raised an exception, if yes
        # raise it here in the function
        if not self.exceptions_queue.empty():
            raise self.exceptions_queue.get()
        return self.results_queue
1088854
@Private
  @Override
  public void completed(final int pTaskletId, final TOutput result) {
    assert taskletId == pTaskletId;
    this.userResult = Optional.ofNullable(result);
    if (callbackHandler != null) {
      executor.execute(new Runnable() {
        @Override
        public void run() {
          callbackHandler.onSuccess(userResult.get());
        }
      });
    }
    this.countDownLatch.countDown();
  }
31179
def block(self, warn_only=False):
        """"""
        self._state = "not finished"
        if self._return_code is None:
            proc = subprocess.Popen(
                self.cmd, cwd=self.cwd, env=self.env,
                stdout=subprocess.PIPE,
                stderr=subprocess.PIPE
            )
            self._stdout, self._stderr = proc.communicate(timeout=self.timeout)
            self._return_code = proc.returncode

        self._state = FINISHED
        if not warn_only:
            self.raise_for_error()
17174
def perform_after(time, block=nil)
      task = Concurrent::ScheduledTask.new(time) do
        block = ->(){ yield } unless block
        self.async.perform_now block
      end
      task.execute
      task
    end
737583
def wait(self, *, timeout=None):
        
        for _ in self.get_results(block=True, timeout=timeout):  # pragma: no cover
            pass
291821
def wait(self):
        
        self.thread.join()
        if self.error is not None:
            return self.error
        return self.result
532849
def wait(self, timeout=None):
        
        self.ev_done.wait(timeout=timeout)

        if not self.ev_done.is_set():
            raise TaskTimeout("Task %s timed out." % self)

        # --> self.result is set
        # If it is an exception, then raise it in this waiter
        if isinstance(self.result, Exception):
            raise self.result

        # Release waiters and perform callbacks
        # done() has already been called, because of self.ev_done check
        # "asynchronous" tasks should could call done() here
        #self.done(self.result)

        return self.result
406682
def wait(self, callback=None):
        
        if self.is_master():
            return

        worker = self.comm.rank
        status = MPI.Status()
        while True:
            log.log(_VERBOSE, "Worker {0} waiting for task".format(worker))

            task = self.comm.recv(source=self.master, tag=MPI.ANY_TAG,
                                  status=status)

            if task is None:
                log.log(_VERBOSE, "Worker {0} told to quit work".format(worker))
                break

            func, arg = task
            log.log(_VERBOSE, "Worker {0} got task {1} with tag {2}"
                    .format(worker, arg, status.tag))

            result = func(arg)

            log.log(_VERBOSE, "Worker {0} sending answer {1} with tag {2}"
                    .format(worker, result, status.tag))

            self.comm.ssend(result, self.master, status.tag)

        if callback is not None:
            callback()
1176915
function processTask() {
        setTimeout(function() {
            if (isBusy || queue.length === 0) {
                return;
            }

            isBusy = true;

            var next = queue.shift(),
                result,
                error;

            Platform.async(function(callback) { // Start a promise chain
                callback();
            })().then(function() {
                return next.task(); // Run the task
            }).then(function(res) { // task completed successfully
                isBusy = false;
                processTask();
                next.callback(null, res); // resolve the promise returned by the run function
            }, function(err) { // task failed
                isBusy = false;
                processTask();
                next.callback(err); // reject the promise returned by the run function
            });
        }, 0);
    }