The entry point for the worker thread.

        Pulls pending data off the queue and writes them in
        batches to the specified tracing backend using the exporter.
549554
def _thread_main(self):
        
        quit_ = False

        while True:
            items = self._get_items()
            data = []

            for item in items:
                if item is _WORKER_TERMINATOR:
                    quit_ = True
                    # Continue processing items, don't break, try to process
                    # all items we got back before quitting.
                else:
                    data.extend(item)

            if data:
                try:
                    self.exporter.emit(data)
                except Exception:
                    logging.exception(
                        '%s failed to emit data.'
                        'Dropping %s objects from queue.',
                        self.exporter.__class__.__name__,
                        len(data))
                    pass

            for _ in range(len(items)):
                self._queue.task_done()

            # self._event is set at exit, at which point we start draining the
            # queue immediately. If self._event is unset, block for
            # self.wait_period between each batch of exports.
            self._event.wait(self._wait_period)

            if quit_:
                break
877245
public void start() {
        if(actionInBackground != null) {

            Runnable jobToRun = new Runnable() {
                @Override
                public void run() {
                    result = (JobResult) actionInBackground.doAsync();
                    onResult();
                }
            };

            if(getExecutorService() != null) {
               asyncFutureTask = (FutureTask) getExecutorService().submit(jobToRun);
            } else {
                asyncThread = new Thread(jobToRun);
                asyncThread.start();
            }
        }
    }
37137
def launch_worker
    @worker_threads << Thread.new {
      while work = @work_queue.pop
        begin
          #RJR::Logger.debug "launch thread pool job #{work}"
          @running_queue << work
          work.exec(@thread_lock)
          # TODO cleaner / more immediate way to pop item off running_queue
          #RJR::Logger.debug "finished thread pool job #{work}"
        rescue Exception => e
          # FIXME also send to rjr logger at a critical level
          puts "Thread raised Fatal Exception #{e}"
          puts "\n#{e.backtrace.join("\n")}"
        end
      end
    }
  end
1107309
def start
      Filum.logger.info "Starting Workerpool"
      Larva::WorkerPool.start(@processors)
      Filum.logger.info "Workerpool Finished"
    end
731794
function(data, showStatus, callback) {
    if (showStatus===undefined) showStatus=true;

    /* Queue our data to write. If there was previous data and no callback to
    invoke on this data or the previous then just append data. This would happen
    if typing in the terminal for example. */
    if (!callback && writeData.length && !writeData[writeData.length-1].callback) {
      writeData[writeData.length-1].data += data;
    } else {
      writeData.push({data:data,callback:callback,showStatus:showStatus});
      /* if this is our first data, start sending now. Otherwise we're already
      busy sending and will pull data off writeData when ready */
      if (writeData.length==1)
        writeSerialWorker(true);
    }
  }
317476
private void startWorkerIfNeeded() {
    // Perform a compare-and-swap retry loop for synchronization to make sure we don't start more
    // workers than desired.
    int currentCount = mPendingWorkers.get();
    while (currentCount < mMaxConcurrency) {
      int updatedCount = currentCount + 1;
      if (mPendingWorkers.compareAndSet(currentCount, updatedCount)) {
        // Start a new worker.
        FLog.v(TAG, "%s: starting worker %d of %d", mName, updatedCount, mMaxConcurrency);
        mExecutor.execute(mTaskRunner);
        break;
      }
      // else: compareAndSet failed due to race; snapshot the new count and try again
      FLog.v(TAG, "%s: race in startWorkerIfNeeded; retrying", mName);
      currentCount = mPendingWorkers.get();
    }
  }
1086787
def start(self):
        
        setproctitle('oq-zworkerpool %s' % self.ctrl_url[6:])  # strip tcp://
        # start workers
        self.workers = []
        for _ in range(self.num_workers):
            sock = z.Socket(self.task_out_port, z.zmq.PULL, 'connect')
            proc = multiprocessing.Process(target=self.worker, args=(sock,))
            proc.start()
            sock.pid = proc.pid
            self.workers.append(sock)

        # start control loop accepting the commands stop and kill
        with z.Socket(self.ctrl_url, z.zmq.REP, 'bind') as ctrlsock:
            for cmd in ctrlsock:
                if cmd in ('stop', 'kill'):
                    msg = getattr(self, cmd)()
                    ctrlsock.send(msg)
                    break
                elif cmd == 'getpid':
                    ctrlsock.send(self.pid)
                elif cmd == 'get_num_workers':
                    ctrlsock.send(self.num_workers)
852392
void start() {
    Runnable r;
    for (int i = 0; i < threadCount; i++) {
      r = null;
      switch (config.getPayloadConfig().getPayloadCase()) {
        case SIMPLE_PARAMS: {
          if (config.getClientType() == Control.ClientType.SYNC_CLIENT) {
            if (config.getRpcType() == Control.RpcType.UNARY) {
              r = new BlockingUnaryWorker(blockingStubs[i % blockingStubs.length]);
            }
          } else if (config.getClientType() == Control.ClientType.ASYNC_CLIENT) {
            if (config.getRpcType() == Control.RpcType.UNARY) {
              r = new AsyncUnaryWorker(asyncStubs[i % asyncStubs.length]);
            } else if (config.getRpcType() == Control.RpcType.STREAMING) {
              r = new AsyncPingPongWorker(asyncStubs[i % asyncStubs.length]);
            }
          }
          break;
        }
        case BYTEBUF_PARAMS: {
          if (config.getClientType() == Control.ClientType.SYNC_CLIENT) {
            if (config.getRpcType() == Control.RpcType.UNARY) {
              r = new GenericBlockingUnaryWorker(channels[i % channels.length]);
            }
          } else if (config.getClientType() == Control.ClientType.ASYNC_CLIENT) {
            if (config.getRpcType() == Control.RpcType.UNARY) {
              r = new GenericAsyncUnaryWorker(channels[i % channels.length]);
            } else if (config.getRpcType() == Control.RpcType.STREAMING) {
              r = new GenericAsyncPingPongWorker(channels[i % channels.length]);
            }
          }

          break;
        }
        default: {
          throw Status.UNIMPLEMENTED.withDescription(
              "Unknown payload case " + config.getPayloadConfig().getPayloadCase().name())
              .asRuntimeException();
        }
      }
      if (r == null) {
        throw new IllegalStateException(config.getRpcType().name()
            + " not supported for client type "
            + config.getClientType());
      }
      fixedThreadPool.execute(r);
    }
    if (osBean != null) {
      lastMarkCpuTime = osBean.getProcessCpuTime();
    }
  }
289563
def finish(self, data=''):
        '''
        
        '''
        self.pending += data
        self.streaming = False
        for i in self:
            yield i
1170996
function proceedWithBackup() {
    if (options.resume) {
      // pick up from existing log file from previous run
      downloadRemainingBatches(options.log, db, ee, start, batchesPerDownloadSession, options.parallelism);
    } else {
      // create new log file and process
      spoolchanges(db, options.log, options.bufferSize, ee, function(err) {
        if (err) {
          ee.emit('error', err);
        } else {
          downloadRemainingBatches(options.log, db, ee, start, batchesPerDownloadSession, options.parallelism);
        }
      });
    }
  }
1243910
def start():
    
    os.write(BenchmarkProcess.BACKCHANNEL_OUT, BenchmarkProcess.START)
    response = util.untilConcludes(os.read, BenchmarkProcess.BACKCHANNEL_IN, 1)
    if response != BenchmarkProcess.START:
        raise RuntimeError(
            "Parent process responded with %r instead of START " % (response,))
42426
@PostConstruct
    public void start() {
        threadFactory = Executors.defaultThreadFactory();
        disruptor = new Disruptor<>(Registration.FACTORY,
                ringSize,
                threadFactory,
                ProducerType.MULTI,
                new BlockingWaitStrategy());
        disruptor.handleEventsWith(new ContainerEventHandler());
        ringBuffer = disruptor.start();
    }
1279873
protected void processQueue() {
        try {
            Collection<RequestMetric> batch = new ArrayList<>(this.batchSize);
            RequestMetric rm = queue.take();
            batch.add(rm);
			queue.drainTo(batch, this.batchSize - 1);
			
			Builder builder = new Bulk.Builder();
			for (RequestMetric metric : batch) {
	            Index index = new Index.Builder(metric).refresh(false)
	                    .index(getIndexName())
	                    .type("request").build(); //$NON-NLS-1$
				builder.addAction(index);
			}
            
            BulkResult result = getClient().execute(builder.build());
            if (!result.isSucceeded()) {
                logger.warn("Failed to add metric(s) to ES"); //$NON-NLS-1$
            }
        } catch (Exception e) {
            logger.warn("Error adding metric to ES"); //$NON-NLS-1$
            return;
        }
    }
490522
def main():
    

    logging.captureWarnings(True)
    logging.basicConfig(format=('%(asctime)s - %(name)s - %(levelname)s - ' +
                                '%(message)s'), level=logging.INFO)

    args = [3, 5, 10, 20]

    # The default queue used by grid_map is all.q. You must specify
    # the `queue` keyword argument if that is not the name of your queue.
    intermediate_results = grid_map(computeFactorial, args, quiet=False,
                                    max_processes=4, queue='all.q')

    # Just print the items instead of really reducing. We could always sum them.
    print("reducing result")
    for i, ret in enumerate(intermediate_results):
        print("f({0}) = {1}".format(args[i], ret))
610135
def start(self, e):
        
        logger.debug("Spawning metric & trace reporting threads")
        self.sensor.meter.run()
        instana.singletons.tracer.recorder.run()
486271
def _create_inbound_thread(self):
        
        inbound_thread = threading.Thread(target=self._process_incoming_data,
                                          name=__name__)
        inbound_thread.daemon = True
        inbound_thread.start()
        return inbound_thread
1197085
def start(self):
        # type: (SyncCopy) -> None
        
        try:
            blobxfer.operations.progress.output_parameters(
                self._general_options, self._spec)
            self._run()
        except (KeyboardInterrupt, Exception) as ex:
            if isinstance(ex, KeyboardInterrupt):
                logger.info(
                    'KeyboardInterrupt detected, force terminating '
                    'processes and threads (this may take a while)...')
            else:
                logger.exception(ex)
            self._wait_for_transfer_threads(terminate=True)
        finally:
            # close resume file
            if self._resume is not None:
                self._resume.close()