Waits for a task which was launched to be launched
973788
def wait_for_task(service, task, timeout_sec=120):
    """"""
    return time_wait(lambda: task_predicate(service, task), timeout_seconds=timeout_sec)
683555
def task_wait(meow, heartbeat, polling_interval, timeout, task_id, timeout_exit_code):
    
    task_wait_with_io(
        meow, heartbeat, polling_interval, timeout, task_id, timeout_exit_code
    )
862272
def join(self, timeout=None):
        """"""
        if not self._started:
            raise RuntimeError('cannot join task before it is started')
        return self._exit_event.wait(timeout)
35100
async def wait_for_send(self, event, *, until=None):
        '''
        
        '''
        while True:
            if until:
                r = until()
                if r:
                    return r
            waiter = self.scheduler.send(event)
            if waiter is None:
                break
            await waiter
593469
def run(self, tasks=None, timeout=None):
        """"""
        timeout = self._timeout if timeout is None else timeout
        if self.async_running or self.loop.is_running():
            return self.wait_all_tasks_done(timeout)
        else:
            tasks = tasks or self.todo_tasks
            return self.loop.run_until_complete(asyncio.gather(*tasks, loop=self.loop))
577544
async def wait(self):
        
        if self._ping_task is None:
            raise RuntimeError('Response is not started')
        with contextlib.suppress(asyncio.CancelledError):
            await self._ping_task
16075
def wait(self):
        
        running = True
        while running and self.messages_pending():
            running = self.do_work()
        return running
637349
def launchTask(self, driver, task):
        
        
        log.debug("Asked to launch task %s", repr(task))
        
        def runTask():

            log.debug("Running task %s", task.task_id.value)
            startTime = time.time()
            sendUpdate(task, 'TASK_RUNNING', wallTime=0)

            # try to unpickle the task
            try:
                taskData = pickle.loads(decode_data(task.data))
            except:
                exc_info = sys.exc_info()
                log.error('Exception while unpickling task: ', exc_info=exc_info)
                exc_type, exc_value, exc_trace = exc_info
                sendUpdate(task, 'TASK_FAILED', wallTime=0, msg=''.join(traceback.format_exception_only(exc_type, exc_value)))
                return

            # This is where task.data is first invoked. Using this position to setup cleanupInfo
            if self.workerCleanupInfo is not None:
                assert self.workerCleanupInfo == taskData.workerCleanupInfo
            else:
                self.workerCleanupInfo = taskData.workerCleanupInfo

            # try to invoke a run on the unpickled task
            try:
                process = runJob(taskData)
                self.runningTasks[task.task_id.value] = process.pid
                try:
                    exitStatus = process.wait()
                    wallTime = time.time() - startTime
                    if 0 == exitStatus:
                        sendUpdate(task, 'TASK_FINISHED', wallTime)
                    elif -9 == exitStatus:
                        sendUpdate(task, 'TASK_KILLED', wallTime)
                    else:
                        sendUpdate(task, 'TASK_FAILED', wallTime, msg=str(exitStatus))
                finally:
                    del self.runningTasks[task.task_id.value]
            except:
                wallTime = time.time() - startTime
                exc_info = sys.exc_info()
                log.error('Exception while running task:', exc_info=exc_info)
                exc_type, exc_value, exc_trace = exc_info
                sendUpdate(task, 'TASK_FAILED', wallTime=wallTime, msg=''.join(traceback.format_exception_only(exc_type, exc_value)))

            wallTime = time.time() - startTime
            sendUpdate(task, 'TASK_FINISHED', wallTime)


        def runJob(job):
            """
            :type job: toil.batchSystems.mesos.ToilJob

            :rtype: subprocess.Popen
            """
            if job.userScript:
                job.userScript.register()
            log.debug("Invoking command: '%s'", job.command)
            # Construct the job's environment
            jobEnv = dict(os.environ, **job.environment)
            log.debug('Using environment variables: %s', jobEnv.keys())
            with self.popenLock:
                return subprocess.Popen(job.command,
                                        preexec_fn=lambda: os.setpgrp(),
                                        shell=True, env=jobEnv)

        def sendUpdate(task, taskState, wallTime=None, msg=''):
            update = addict.Dict()
            update.task_id.value = task.task_id.value
            if self.id is not None:
                # Sign our messages as from us, since the driver doesn't do it.
                update.executor_id.value = self.id
            update.state = taskState
            update.timestamp = wallTime
            update.message = msg
            driver.sendStatusUpdate(update)

        thread = threading.Thread(target=runTask)
        thread.start()
189130
def wait_and_join(self, task):
        
        while not task.has_started:
            time.sleep(self._polling_time)
        task.thread.join()
617209
public void waitForReady() {
        if (!isLoaded) {
            synchronized (LOAD_LOCK) {
                if (!isLoaded) {
                    try {
                        long start = Runtime.getActorTime();
                        LOAD_LOCK.wait();
                        Log.d(TAG, "Waited for startup in " + (Runtime.getActorTime() - start) + " ms");
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                }
            }
        }
    }
310304
private void waitForTaskToFinish(Future<?> future, long timeout, TimeUnit unit) throws Exception {
      try {
         future.get(timeout, unit);
      } catch (TimeoutException e) {
         throw new Exception("task timed out", e);
      } catch (InterruptedException e) {
         /* Re-assert the thread's interrupted status */
         Thread.currentThread().interrupt();
         if (trace) log.trace("task was interrupted");
      } finally {
         /* no-op if task is completed */
         future.cancel(true); /* interrupt if running */
      }
   }
329800
public void waitUntilFinished()
    {
        flushTermination();
        flushUpdate();
        flushInsert();
        shutdown();
        for (int i = 0; i < numberOfQueues; i++)
        {
            while (!executors[i].isTerminated())
            {
                try
                {
                    executors[i].awaitTermination(10000000, TimeUnit.SECONDS);
                }
                catch (InterruptedException e)
                {
                    // ignore
                }
            }
        }
        if (useBulkInsert)
        {
            bulkInsert();
        }
        logFinalResults();
        if (this.error != null)
        {
            if (error instanceof RuntimeException)
            {
                throw (RuntimeException) error;
            } else
            {
                throw new RuntimeException("One or more parallel tasks failed", this.error);
            }
        }
    }
313435
private void awaitTasks() {
        if (_tasksPending.get() == 0) {
            return;
        }
        synchronized (this) {
            while (_tasksPending.get() != 0) {
                try {
                    logger.info("Scan tasks still pending, waiting");
                    wait();
                } catch (final InterruptedException e) {
                    logger.debug("Interrupted while awaiting task completion", e);
                }
            }
        }
    }
1297826
def wait_for_task(upid, timeout=300):
    '''
    
    '''
    start_time = time.time()
    info = _lookup_proxmox_task(upid)
    if not info:
        log.error('wait_for_task: No task information '
                  'retrieved based on given criteria.')
        raise SaltCloudExecutionFailure

    while True:
        if 'status' in info and info['status'] == 'OK':
            log.debug('Task has been finished!')
            return True
        time.sleep(3)  # Little more patience, we're not in a hurry
        if time.time() - start_time > timeout:
            log.debug('Timeout reached while waiting for task to be finished')
            return False
        info = _lookup_proxmox_task(upid)
1217970
protected boolean waitForTasks() {
		synchronized (this.tasks) {
			while (!this.closed && !this.hasTaskPending()) {
				try {
					this.tasks.wait();
				} catch (InterruptedException e) {
					e.printStackTrace();
				}
			}
		}

		return !this.closed;
	}
1244480
def start_waiting(self):
        
        if not self.waiting:
            self.waiting = True
            wait_msg = "Waiting for project to become ready for {}".format(self.msg_verb)
            self.progress_bar.show_waiting(wait_msg)
120479
def wait_for_tasks(self):
        
        finished_tasks_and_results = []
        while len(finished_tasks_and_results) == 0:
            if self.is_done():
                break
            self.start_tasks()
            self.process_all_messages_in_queue()
            finished_tasks_and_results = self.get_finished_results()
        return finished_tasks_and_results