Create a new workunit under the calling thread's current workunit.

    :API: public
516522
def new_workunit(self, name, labels=None, cmd='', log_config=None):
    
    with self.run_tracker.new_workunit(name=name, labels=labels, cmd=cmd, log_config=log_config) as workunit:
      yield workunit
703480
def start(self):
        
        self.broker.emit_before("worker_boot", self)

        worker_middleware = _WorkerMiddleware(self)
        self.broker.add_middleware(worker_middleware)
        for _ in range(self.worker_threads):
            self._add_worker()

        self.broker.emit_after("worker_boot", self)
576211
private void addNewWorkUnits(MultiWorkUnitWeightedQueue multiWorkUnitWeightedQueue) {
    try {
      List<PartitionAwareFileRetriever.FileInfo> filesToPull =
          retriever.getFilesToProcess(this.lowWaterMark, this.maxFilesPerJob - this.fileCount);
      Collections.sort(filesToPull);
      String topicName = this.sourceDir.getName();
      String namespace = this.sourceState.getProp(ConfigurationKeys.EXTRACT_NAMESPACE_NAME_KEY);

      Map<Long, Extract> extractMap = new HashMap<>();
      for (PartitionAwareFileRetriever.FileInfo file : filesToPull) {
        Extract extract = getExtractForFile(file, topicName, namespace, extractMap);

        LOG.info("Will process file " + file.getFilePath());

        WorkUnit singleWorkUnit = WorkUnit.create(extract);
        singleWorkUnit.setProp(ConfigurationKeys.SOURCE_ENTITY, topicName);
        singleWorkUnit.setProp(ConfigurationKeys.SOURCE_FILEBASED_FILES_TO_PULL, file.getFilePath());
        singleWorkUnit.setProp(ConfigurationKeys.WORK_UNIT_LOW_WATER_MARK_KEY, file.getWatermarkMsSinceEpoch());
        singleWorkUnit.setProp(ConfigurationKeys.WORK_UNIT_HIGH_WATER_MARK_KEY, file.getWatermarkMsSinceEpoch());
        singleWorkUnit.setProp(ConfigurationKeys.WORK_UNIT_DATE_PARTITION_KEY, file.getWatermarkMsSinceEpoch());
        singleWorkUnit.setProp(ConfigurationKeys.WORK_UNIT_DATE_PARTITION_NAME, file.getPartitionName());
        if (this.sourceState.getPropAsBoolean(ConfigurationKeys.SCHEMA_IN_SOURCE_DIR,
            ConfigurationKeys.DEFAULT_SCHEMA_IN_SOURCE_DIR)) {
          addSchemaFile(file, singleWorkUnit);
        }

        multiWorkUnitWeightedQueue.addWorkUnit(singleWorkUnit, file.getFileSize());

        this.fileCount++;
      }

      LOG.info("Total number of files extracted for the current run: " + filesToPull.size());
    } catch (IOException e) {
      Throwables.propagate(e);
    }
  }
731606
def create_thread(*args)
      return if pool_closed?
      thread = nil
      @lock.synchronize do
        if(args.include?(:nowait) || action_size > size || action_size > waiting || args.include?(:force))
          if(size < max || args.include?(:force))
            thread = ActionPool::Thread.new(:pool => self, :respond_thread => @respond_to,
              :a_timeout => @action_timeout, :t_timeout => @thread_timeout, :logger => @logger,
              :autostart => false)
            @threads << thread
          end
        end
        if(((size == working || args.include?(:nowait)) && @threads.size < @max_threads) || args.include?(:force))

        end
      end
      thread.start if thread
      thread
    end
122702
def new_worker(self, name: str):
        """"""
        if not self.running:
            return self.immediate_worker
        worker = self._new_worker(name)
        self._start_worker(worker)
        return worker
964996
def create(self, **kwargs):
        
        obj = self.resource(**kwargs)
        obj.save(force_insert=True)
        return obj
551027
def join(self, *args, **kwargs):
        
        super(ThreadReturn, self).join(*args, **kwargs)
        return self._return
940441
def createWorkers(self, num_workers):
        
        for i in range(num_workers):
            self.workers.append(WorkerThread(self._requests_queue))
641879
function WorkQueue(obj) {
  if (!(this instanceof WorkQueue)) {
    return new WorkQueue(obj);
  }

  obj = obj || {};

  this.work = [];
  this.workers = [];
  this.nextWorker = 0;
}
1221231
def start(self, nb_threads: int) -> None:
        
        if self._active_threads:
            raise Exception('Threads already started.')

        # Create thread pool
        for _ in range(nb_threads):
            worker = threading.Thread(
                target=_work_function,
                args=(self._job_q, self._result_q, self._error_q))
            worker.start()
            self._thread_list.append(worker)
            self._active_threads += 1

        # Put sentinels to let the threads know when there's no more jobs
        for _ in self._thread_list:
            self._job_q.put(_ThreadPoolSentinel())
1199370
def worker(self):
        
        if self._worker is None:
            self._worker = XOrbLookupWorker(self.isThreadEnabled())
            
            # create worker connections
            self.loadRequested.connect(self._worker.loadRecords)
            self.loadBatchRequested.connect(self._worker.loadBatch)
            self.loadColumnsRequested.connect(self._worker.loadColumns)
            
            self._worker.loadingStarted.connect(self.markLoadingStarted)
            self._worker.loadingFinished.connect(self.markLoadingFinished)
            self._worker.loadedRecords[object].connect(self._loadRecords)
            self._worker.loadedRecords[object, object].connect(self._loadRecords)
            self._worker.loadedGroup.connect(self.createGroupItem)
            self._worker.columnLoaded.connect(self._loadColumns)
            self._worker.connectionLost.connect(self._connectionLost)
            
        return self._worker
209074
def _create_worker(self, method, *args, **kwargs):
        """"""
        # FIXME: this might be heavy...
        thread = QThread()
        worker = ClientWorker(method, args, kwargs)
        worker.moveToThread(thread)
        worker.sig_finished.connect(self._start)
        worker.sig_finished.connect(thread.quit)
        thread.started.connect(worker.start)
        self._queue.append(thread)
        self._threads.append(thread)
        self._workers.append(worker)
        self._start()
        return worker
856517
def create(self, project, subject, **attrs):
        
        attrs.update({'project': project, 'subject': subject})
        return self._new_resource(payload=attrs)
74704
def spawn_thread(self):
        ''
        self.thread = threading.Thread(target=self.run, args=(False,))
        self.thread.daemon = True
        self.thread.start()
17663
def start(self):
        
        with self._operational_lock:
            if self.is_alive:
                return

            self._thread = threading.Thread(
                target=self._thread_main, name=_WORKER_THREAD_NAME
            )
            self._thread.daemon = True
            self._thread.start()
            atexit.register(self._main_thread_terminated)
51613
def instantiate(self):
        
        if self.instance is None:
            self.instance = checked_call(self.cls, self.kwds)
        #endif
        try:
            self.instance.yaml_src = self.yaml_src
        except AttributeError:
            pass
        return self.instance
373369
def _create_worker(self, method, *args, **kwargs):
        """"""
        thread = QThread()
        worker = RequestsDownloadWorker(method, args, kwargs)
        worker.moveToThread(thread)
        worker.sig_finished.connect(self._start)
        self._sig_download_finished.connect(worker.sig_download_finished)
        self._sig_download_progress.connect(worker.sig_download_progress)
        worker.sig_finished.connect(thread.quit)
        thread.started.connect(worker.start)
        self._queue.append(thread)
        self._threads.append(thread)
        self._workers.append(worker)
        self._start()
        return worker