Blocking version of preprocess_async(). The only difference is that it blocks the caller
     until the job finishes, and it does not have a return value.
428503
def preprocess(train_dataset, output_dir, eval_dataset=None, checkpoint=None, cloud=None):
  
  with warnings.catch_warnings():
    warnings.simplefilter("ignore")
    job = preprocess_async(train_dataset, output_dir, eval_dataset, checkpoint, cloud)
    job.wait()
    print(job.state)
859601
async def _delay(self):
        
        if self._response is None:
            await asyncio.sleep(0)
        if self._response.headers.get('retry-after'):
            await asyncio.sleep(int(self._response.headers['retry-after']))
        else:
            await asyncio.sleep(self._timeout)
653835
def _limit_call_handler(self):
        
        # acquire a lock on our threading.Lock() object
        with self.limit_lock:
            # if we have no configured limit, exit.  the lock releases based on scope
            if self.limit_per_min <= 0:
                return

            now = time.time()
            # self.limits is a list of query times + 60 seconds.  In essence it is a list of times
            # that queries time out of the 60 second query window.

            # this check expires any limits that have passed
            self.limits = [l for l in self.limits if l > now]
            # and we tack on the current query
            self.limits.append(now + 60)

            # if we have more than our limit of queries (and remember, we call this before we actually
            # execute a query) we sleep until the oldest query on the list (element 0 because we append
            # new queries) times out.  We don't worry about cleanup because next time this routine runs
            # it will clean itself up.
            if len(self.limits) >= self.limit_per_min:
                time.sleep(self.limits[0] - now)
450199
def do_wait(coro: Callable) -> Any:
    

    event_loop = None
    try:
        event_loop = asyncio.get_event_loop()
    except RuntimeError:
        event_loop = asyncio.new_event_loop()
        asyncio.set_event_loop(event_loop)
    return event_loop.run_until_complete(coro)
1027299
def do_callback(self, pkt):
        
        callback, parser = self.get_callback_parser(pkt)

        if asyncio.iscoroutinefunction(callback):
            self.loop.call_soon_threadsafe(self._do_async_callback,
                                           callback, parser)
        else:
            self.loop.call_soon(callback, parser)
957938
def defer(callable):
    '''
    '''
    t = threading.Thread(target=callable)
    t.start()
    return t.join
1080173
def block(self):
        

        self._nosig = True
        yield
        self._nosig = False
        if self._interrupted:
            raise SystemExit("Aborted...")
993344
public static <ReqT, RespT> Iterator<RespT> blockingServerStreamingCall(
      Channel channel, MethodDescriptor<ReqT, RespT> method, CallOptions callOptions, ReqT req) {
    ThreadlessExecutor executor = new ThreadlessExecutor();
    ClientCall<ReqT, RespT> call = channel.newCall(method, callOptions.withExecutor(executor));
    BlockingResponseStream<RespT> result = new BlockingResponseStream<>(call, executor);
    asyncUnaryRequestCall(call, req, result.listener(), true);
    return result;
  }
542980
function preprocessorcery(infile, info, callback) {
  applicable(infile, info, (err, preprocessors) => {
    if (err) return callback(err);

    const q = queue(1);
    preprocessors.forEach((preprocessor) => {
      const outfile = newfile(infile);
      q.defer((next) => {
        preprocessor(infile, outfile, (err) => {
          if (err) return next(err);
          infile = outfile;
          next();
        });
      });
    });

    q.await((err) => {
      if (err) return callback(err);

      // infile has been changed to the output file by this point
      callback(null, infile);
    });
  });
}
1179350
def has_blocking_background_send(self):
		
		for background_object in self.background_objects:
			# If it's running, or not started yet, it should block other tasks.
			if background_object.block_other_commands and background_object.run_state in ('S','N'):
				self.shutit_obj.log('All objects are: ' + str(self),level=logging.DEBUG)
				self.shutit_obj.log('The current blocking send object is: ' + str(background_object),level=logging.DEBUG)
				return True
			elif background_object.block_other_commands and background_object.run_state in ('F','C','T'):
				assert False, shutit_util.print_debug(msg='Blocking command should have been removed, in run_state: ' + background_object.run_state)
			else:
				assert background_object.block_other_commands is False, shutit_util.print_debug()
		return False
1338864
public static <ReqT, RespT> RespT blockingUnaryCall(ClientCall<ReqT, RespT> call, ReqT req) {
    try {
      return getUnchecked(futureUnaryCall(call, req));
    } catch (RuntimeException e) {
      throw cancelThrow(call, e);
    } catch (Error e) {
      throw cancelThrow(call, e);
    }
  }
252627
public EventResultDisruptor waitForBlocking() {
		SequenceBarrier barrier = ringBuffer.newBarrier();
		try {
			long a = barrier.waitFor(waitAtSequence);
			if (ringBuffer != null)
				return ringBuffer.get(a);
		} catch (Exception e) {
			e.printStackTrace();
		} finally {
			barrier.alert();
		}
		return null;
	}
1059392
function () {

        // get a event from the front of queue
        var tmdata = queue.dequeue();

        // whether to keep processing (default is no)
        busy = false;

        // check if data exists
        if (tmdata === undefined) {
            return;
        }

        // handle the event if handler is available
        if (handler === null) {
            console.log(SR.Tags.ERR + 'handler undefined, cannot process event' + ERREND);
            return;
        }
                        
        switch (handler(tmdata)) {

            // if the event is not handled, re-queue it
            case false:
                queue.enqueue(tmdata);
                break;
                
            // return true, keep processing
            case true:
                break;
            
            /*
            // NOTE: we do not pause continuing execution, because it's possible for a event
            //         to consider it finished, re-activate the queue (which it think it has paused), 
            //       but then the execution runs to the end of handler, and returning a undefine to pause icQueue
            //       this will thus cause a event to indefinitely pause without any on-going progress.
            //
            //         Currently if the event has returned, we assume it's been processed. 
            //         If not yet, then it's up to the handler to re-enqueue the event (by returning 'false')
            //       note that it's possible that the previous event is still being processed 
            //       (for example, waiting for DB to return), while the next event starts processing
            //       so the ordering may not be preserved.
            //       The assumption we have is that events are relatively independent from each other
            //       so such out-of-sequence processing may be "okay," as long as handler will properly re-queue the event
            //       in case it needs to be processed again
            // 
            */

            // did not return anything, pause execution
            default:
                //console.log(SR.Tags.WARN + 'pause processing event, callee: ' + arguments.callee.name);
                return;
                break;                
        }            
        
        // keep processing
        busy = true;
        UTIL.asyncCall(processEvent);
    }
1070702
async def stop_async(self):
        
        self.cancellation_token.cancel()
        if self.run_task and not self.run_task.done():
            await self.run_task
736902
def stop(self, timeout=None):
        
        if timeout is not None:
            log.warning('timeout argument to stop() is deprecated - '
                        'it will be removed in future release')

        if not self.async_send:
            log.warning('producer.stop() called, but producer is not async')
            return

        if self.stopped:
            log.warning('producer.stop() called, but producer is already stopped')
            return

        if self.async_send:
            self.queue.put((STOP_ASYNC_PRODUCER, None, None))
            self.thread_stop_event.set()
            self.thread.join()

        if hasattr(self, '_cleanup_func'):
            # Remove cleanup handler now that we've stopped

            # py3 supports unregistering
            if hasattr(atexit, 'unregister'):
                atexit.unregister(self._cleanup_func)  # pylint: disable=no-member

            # py2 requires removing from private attribute...
            else:

                # ValueError on list.remove() if the exithandler no longer exists
                # but that is fine here
                try:
                    atexit._exithandlers.remove(  # pylint: disable=no-member
                        (self._cleanup_func, (self,), {}))
                except ValueError:
                    pass

            del self._cleanup_func

        self.stopped = True
1066013
@Override public V get() {
    // check priorities - FJ task can only block on a task with higher priority!
    Thread cThr = Thread.currentThread();
    int priority = (cThr instanceof FJWThr) ? ((FJWThr)cThr)._priority : -1;
    assert _dt.priority() > priority || (_dt.priority() == priority && _dt instanceof MRTask)
      : "*** Attempting to block on task (" + _dt.getClass() + ") with equal or lower priority. Can lead to deadlock! " + _dt.priority() + " <=  " + priority;
    if( _done ) return result(); // Fast-path shortcut, or throw if exception
    // Use FJP ManagedBlock for this blocking-wait - so the FJP can spawn
    // another thread if needed.
    try { ForkJoinPool.managedBlock(this); } catch( InterruptedException ignore ) { }
    if( _done ) return result(); // Fast-path shortcut or throw if exception
    assert isCancelled();
    return null;
  }
1049462
async def block(self) -> None:
        """"""
        await asyncio.gather(
            *itertools.chain(
                (sp.wait_done() for sp in self._running_set),
                (sp.wait_done() for sp in self._pending_set)))