Checks for stalled uploading tasks.
552949
function(){

		var view = "_design/searchJob/_view/jobstatus?key=" + JSON.stringify('UPLOADING');
	    return server.methods.clusterprovider.getView(view)
	    .then(function(docs){
	    	return Promise.map(_.pluck(docs, "value"), server.methods.cronprovider.addJobToUpdateQueue);
	    })
	    .catch(console.error);
		
	}
879025
def _check_release_done_processing(release):
    """"""
    if release.status != models.Release.PROCESSING:
        # NOTE: This statement also guards for situations where the user has
        # prematurely specified that the release is good or bad. Once the user
        # has done that, the system will not automatically move the release
        # back into the 'reviewing' state or send the email notification below.
        logging.info('Release not in processing state yet: build_id=%r, '
                     'name=%r, number=%d', release.build_id, release.name,
                     release.number)
        return False

    query = models.Run.query.filter_by(release_id=release.id)
    for run in query:
        if run.status == models.Run.NEEDS_DIFF:
            # Still waiting for the diff to finish.
            return False
        if run.ref_config and not run.ref_image:
            # Still waiting for the ref capture to process.
            return False
        if run.config and not run.image:
            # Still waiting for the run capture to process.
            return False

    logging.info('Release done processing, now reviewing: build_id=%r, '
                 'name=%r, number=%d', release.build_id, release.name,
                 release.number)

    # Send the email at the end of this request so we know it's only
    # sent a single time (guarded by the release.status check above).
    build_id = release.build_id
    release_name = release.name
    release_number = release.number

    @utils.after_this_request
    def send_notification_email(response):
        emails.send_ready_for_review(build_id, release_name, release_number)

    release.status = models.Release.REVIEWING
    db.session.add(release)
    return True
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)
569087
def wait_for_compactions(self, timeout=120):
        
        pattern = re.compile("pending tasks: 0")
        start = time.time()
        while time.time() - start < timeout:
            output, err, rc = self.nodetool("compactionstats")
            if pattern.search(output):
                return
            time.sleep(1)
        raise TimeoutError("{} [{}] Compactions did not finish in {} seconds".format(time.strftime("%d %b %Y %H:%M:%S", time.gmtime()), self.name, timeout))
100466
def is_running(self, submissionid, user_check=True):
        
        submission = self.get_submission(submissionid, user_check)
        return submission["status"] == "waiting"
261024
public void waitBackgroundTaskFinished() throws Exception {
        boolean upToDate;
        synchronized (currentIndexes) {
            upToDate = classpathVersion == indexVersion;
        }
        while (!upToDate) {
            INDEXER.submit(() -> {}).get();
            synchronized (currentIndexes) {
                upToDate = classpathVersion == indexVersion;
            }
        }
    }
922412
private void checkReady() {
    if (allReady()) {
      log.debug(String.format("%s - All components ready in network, starting components", NetworkManager.this));
      // Set the network's status key to the current context version. This
      // can be used by listeners to determine when a configuration change is complete.
      data.put(currentContext.status(), currentContext.version(), new Handler<AsyncResult<String>>() {
        @Override
        public void handle(AsyncResult<String> result) {
          if (result.failed()) {
            log.error(result.cause());
          }
        }
      });
    }
  }
19052
def stalled(self, offset=0, count=25):
        ''''''
        return self.client('jobs', 'stalled', self.name, offset, count)
264180
function() {
      var i = 0;
      grunt.log.writeln( 'Ensuring directories:' );

      var ensureDir = function( dir ) {
        grunt.log.ok( options.remoteDir + dir );

        if ( directoriesChecked.indexOf( dir ) > -1 && ((i + 1) < dirs.length) ) {
          directoriesChecked.push( dir );
          i += 1;
          ensureDir( dirs[ i ] );
        } else if ( i >= dirs.length ) {
          uploadFiles();
        } else {
          directoriesChecked.push( dir );
          client
            .raw( 'mkdir -p "' + options.remoteDir + dir + '"' )
            .exec(function( err, res ) {
              if ( err ) {
                grunt.log.error( err );
              }

              if ( (i + 1) < dirs.length ) {
                 i += 1;
                ensureDir( dirs[ i ] );
              } else {
                uploadFiles();
              }
            });
        }
      };

      if ( dirs.length > 0 ) {
        ensureDir( dirs[0] );
      }
    }
952390
void afterCompletion(Task task) {
        boolean delayable = schedule(task);
        DrainStatus status = drainStatus.get();
        if (status.shouldDrainBuffers(delayable)) {
            tryToDrainBuffers();
        }
        notifyListener();
    }
539299
def _flush(self):
        
        # Initialize multipart upload
        if self._upload_id is None:
            with _handle_oss_error():
                self._upload_id = self._bucket.init_multipart_upload(
                    self._key).upload_id

        # Upload part with workers
        response = self._workers.submit(
            self._bucket.upload_part, key=self._key, upload_id=self._upload_id,
            part_number=self._seek, data=self._get_buffer().tobytes())

        # Save part information
        self._write_futures.append(
            dict(response=response, part_number=self._seek))
55318
function() {
            var waitingOrConnected = connectionManager.getWaitingOrConnected(),
                i;

            // ensure files are cancelled in reverse order which they were added
            // to avoid a flash of time where a queued file begins to upload before it is canceled
            if (waitingOrConnected.length) {
                for (i = waitingOrConnected.length - 1; i >= 0; i--) {
                    controller.cancel(waitingOrConnected[i]);
                }
            }

            connectionManager.reset();
        }
1044329
private S waitForCompletionAndThrowIfUploadFailed() throws IOException {
    try {
      return uploadOperation.get();
    } catch (InterruptedException e) {
      // If we were interrupted, we need to cancel the upload operation.
      uploadOperation.cancel(true);
      IOException exception = new ClosedByInterruptException();
      exception.addSuppressed(e);
      throw exception;
    } catch (ExecutionException e) {
      if (e.getCause() instanceof Error) {
        throw (Error) e.getCause();
      }
      throw new IOException("Upload failed", e.getCause());
    }
  }
1279861
def clear_stalled_files(self):
        
        # FIXME: put lock in directory?
        CLEAR_AFTER = self.config["DELETE_STALLED_AFTER"]
        minimum_age = time.time() - CLEAR_AFTER

        for user_dir in self.UPLOAD_DIR.iterdir():
            if not user_dir.is_dir():
                logger.error("Found non-directory in upload dir: %r", bytes(user_dir))
                continue

            for content in user_dir.iterdir():
                if not content.is_file():
                    logger.error(
                        "Found non-file in user upload dir: %r", bytes(content)
                    )
                    continue

                if content.stat().st_ctime < minimum_age:
                    content.unlink()
943855
def join(self, ignore_errors=False):
    """"""
    assert self._status_fn, "Asked to join a task which hasn't had any commands executed on it"
    check_interval = 0.2
    status_fn = self._status_fn
    if not self.wait_for_file(status_fn, max_wait_sec=30):
      self.log(f"Retrying waiting for {status_fn}")
    while not self.exists(status_fn):
      self.log(f"Still waiting for {self._cmd}")
      self.wait_for_file(status_fn, max_wait_sec=30)
    contents = self.read(status_fn)

    # if empty wait a bit to allow for race condition
    if len(contents) == 0:
      time.sleep(check_interval)
      contents = self.read(status_fn)
    status = int(contents.strip())
    self.last_status = status

    if status != 0:
      extra_msg = '(ignoring error)' if ignore_errors else '(failing)'
      if util.is_set('NCLUSTER_RUN_WITH_OUTPUT_ON_FAILURE') or True:
        self.log(
          f"Start failing output {extra_msg}: \n{'*'*80}\n\n '{self.read(self._out_fn)}'")
        self.log(f"\n{'*'*80}\nEnd failing output")
      if not ignore_errors:
        raise RuntimeError(f"Command {self._cmd} returned status {status}")
      else:
        self.log(f"Warning: command {self._cmd} returned status {status}")

    return status
799973
def _upload_check(self, upload_info, resumable=False):
        """"""
        return self._api.upload_check(
            filename=upload_info.name,
            size=upload_info.size,
            hash_=upload_info.hash_info.file,
            folder_key=upload_info.folder_key,
            filedrop_key=upload_info.filedrop_key,
            path=upload_info.path,
            resumable=resumable
        )
868799
def finish_upload_and_wait(self, component, length,
                               timeout=2, interval=0.1):
        
        try:
            rsp = self.finish_firmware_upload(component, length)
            check_completion_code(rsp.completion_code)
        except CompletionCodeError as e:
            if e.cc == CC_LONG_DURATION_CMD_IN_PROGRESS:
                self.wait_for_long_duration_command(
                            constants.CMDID_HPM_FINISH_FIRMWARE_UPLOAD,
                            timeout, interval)
            else:
                raise HpmError('finish_firmware_upload CC=0x%02x' % e.cc)