returns worker thread names that supposely belong to the current application
493170
def worker_thread_ids
      thread_group = java.lang.Thread.currentThread.getThreadGroup
      threads = java.lang.reflect.Array.newInstance(
        java.lang.Thread.java_class, thread_group.activeCount)
      thread_group.enumerate(threads)
      # NOTE: we shall check the name from $servlet_context.getServletContextName
      # but that's an implementation detail of the factory currently that threads
      # are named including their context name. thread grouping should be fine !
      threads.map do |thread| # a convention is to name threads as "worker" :
        thread && thread.getName.index(WORKER_THREAD_ID) ? thread.getName : nil
      end.compact
    end
458917
private ThreadGroup getRootThreadGroup() {
	
	    if ( rootThreadGroup != null )
	        return rootThreadGroup;
	    
	    ThreadGroup tg = Thread.currentThread( ).getThreadGroup( );
	    ThreadGroup ptg;
	    while ( (ptg = tg.getParent( )) != null )
	        tg = ptg;
	    
	    return tg;
		
	}
343740
protected synchronized List<String> getActiveWorkerInstances() {
        List<String> localList = new ArrayList<String>();
        int activeServerInterval = PropertyManager.getIntegerProperty(PropertyNames.MDW_ROUTING_ACTIVE_SERVER_INTERVAL, 15);   // Represents how many seconds between checks

        if (lastCheck == 0 || ((System.currentTimeMillis() - lastCheck)/1000) > activeServerInterval) {
            lastCheck = System.currentTimeMillis();
            activeServerList.clear();
            for(String server : getWorkerInstances()) {
                try {
                    HttpHelper helper = new HttpHelper(new URL("http://" + server + "/" + ApplicationContext.getServicesContextRoot() + "/Services/SystemInfo?type=threadDumpCount&format=text"));
                    helper.setConnectTimeout(1000);     // Timeout after 1 second
                    helper.setReadTimeout(1000);
                    String response = helper.get();

                    if (!StringHelper.isEmpty(response) && Integer.parseInt(response) > 0 && !activeServerList.contains(server))
                        activeServerList.add(server);
                }
                catch (Exception ex) {
                    if (activeServerList.contains(server))
                        activeServerList.remove(server);

                    logger.info("MDW Server instance " + server + " is not responding");
                }
            }
            lastCheck = System.currentTimeMillis();
        }

        // If all worker instances are non-responsive, still try to send it to one of them - Don't want routing instance to process request
        // Could be they just did a cache refresh or initial startup and couldn't respond in < 1 second - First request
        if (activeServerList.isEmpty()) {
            for (String server : getWorkerInstances())
                activeServerList.add(server);
        }

        for (String server : activeServerList)
            localList.add(server);

        return localList;
    }
920
def thread_data(name, value=NOTHING, ct=None):
    '''
    '''
    ct = ct or current_thread()
    if is_mainthread(ct):
        loc = process_data()
    elif not hasattr(ct, '_pulsar_local'):
        ct._pulsar_local = loc = {}
    else:
        loc = ct._pulsar_local
    if value is not NOTHING:
        if name in loc:
            if loc[name] is not value:
                raise RuntimeError(
                    '%s is already available on this thread' % name)
        else:
            loc[name] = value
    return loc.get(name)
1050261
def _StatusUpdateThreadMain(self):
    """"""
    while self._status_update_active:
      # Make a local copy of the PIDs in case the dict is changed by
      # the main thread.
      for pid in list(self._process_information_per_pid.keys()):
        self._CheckStatusWorkerProcess(pid)

      self._UpdateForemanProcessStatus()

      tasks_status = self._task_manager.GetStatusInformation()
      if self._task_queue_profiler:
        self._task_queue_profiler.Sample(tasks_status)

      self._processing_status.UpdateTasksStatus(tasks_status)

      if self._status_update_callback:
        self._status_update_callback(self._processing_status)

      time.sleep(self._STATUS_UPDATE_INTERVAL)
184810
def workers(self):
        """"""
        worker_keys = self.redis_client.keys("Worker*")
        workers_data = {}

        for worker_key in worker_keys:
            worker_info = self.redis_client.hgetall(worker_key)
            worker_id = binary_to_hex(worker_key[len("Workers:"):])

            workers_data[worker_id] = {
                "node_ip_address": decode(worker_info[b"node_ip_address"]),
                "plasma_store_socket": decode(
                    worker_info[b"plasma_store_socket"])
            }
            if b"stderr_file" in worker_info:
                workers_data[worker_id]["stderr_file"] = decode(
                    worker_info[b"stderr_file"])
            if b"stdout_file" in worker_info:
                workers_data[worker_id]["stdout_file"] = decode(
                    worker_info[b"stdout_file"])
        return workers_data
1353956
protected static function getAllWorkerPids()
    {
        $pid_array = array();
        foreach (static::$_pidMap as $worker_pid_array) {
            foreach ($worker_pid_array as $worker_pid) {
                $pid_array[$worker_pid] = $worker_pid;
            }
        }
        return $pid_array;
    }
436067
def ListThreads(self):
    
    if self.inferior.is_running:
      return self.inferior.threads
    logging.error('Not attached to any process.')
    return []
1085590
def worker_thread(self):
        
        self.thread_debug("Starting monitor thread")
        while not self.thread_stopper.is_set():
            mon = self.workers_queue.get()
            self.thread_debug("Processing {type} Monitor: {title}".format(**mon))
            result = getattr(self, "_worker_" + mon['type'])(mon)
            self.workers_queue.task_done()
            self.results_queue.put({'type':mon['type'], 'result':result})
1250316
def worker_thread(context):
    """"""
    queue = context.task_queue
    parameters = context.worker_parameters

    if parameters.initializer is not None:
        if not run_initializer(parameters.initializer, parameters.initargs):
            context.state = ERROR
            return

    for task in get_next_task(context, parameters.max_tasks):
        execute_next_task(task)
        queue.task_done()
3432
def workers():
    """"""
    counter = Counter()
    for w in Worker.all(connection=worker.connection):
        for q in w.queues:
            counter[q.name] += 1
    import pprint
    pprint.pprint(dict(counter))
1031353
public String getThreadName() {
        if (mThreadName == null) {
            Thread t = getThread();
            if (t != null) {
                mThreadName = t.getName();
            }
        }
        return mThreadName;
    }
516768
public String currentStatus() {
        StringBuffer sb = new StringBuffer();
        sb.append("===== CommonThreadPool Status at ").append(new Date()).append(" =====\n");
        sb.append("Threads: current=").append(thread_pool.getPoolSize());
        sb.append(", core=").append(thread_pool.getCorePoolSize());
        sb.append(", max=").append(thread_pool.getMaximumPoolSize());
        sb.append(", active=").append(thread_pool.getActiveCount()).append("\n");
        BlockingQueue<Runnable> workQueue = thread_pool.getQueue();
        sb.append("Queue: current=").append(workQueue.size()).append("\n");
        sb.append("Works: total=").append(thread_pool.getTaskCount());
        sb.append(", completed=").append(thread_pool.getCompletedTaskCount()).append("\n");
        for (String name : workers.keySet()) {
            Worker worker = workers.get(name);
            sb.append(" - Worker ").append(name);
            sb.append(": current works=").append(worker.curWorks);
            sb.append(", current thread=").append(worker.curThreads);
            sb.append(", total submit=").append(worker.totalSubmits);
            sb.append(", total reject=").append(worker.totalRejects).append("\n");
        }
        Worker worker = defaultWorker;
        sb.append(" - Default Worker: ");
        sb.append(": current works=").append(worker.curWorks);
        sb.append(", current thread=").append(worker.curThreads);
        sb.append(", total submit=").append(worker.totalSubmits);
        sb.append(", total reject=").append(worker.totalRejects).append("\n");
        return sb.toString();
    }
151814
public static String getThreadName(String name){
        if(name==null || name.isEmpty()){
            return SD_THREAD_PREFIX + nextIndex();
        }
        return SD_THREAD_PREFIX + name + "_" + nextIndex();
    }
61239
def threadid(self):
        
        current = self.thread.ident
        main = get_main_thread()
        if main is None:
            return current
        else:
            return current if current != main.ident else None
1306951
protected function getRunningWorkerPids(){
        $workerPids = [];
        $workerPidsInRedis = $this->redisClientForStatics->keys(self::worker_status_monitoring_key_prefix.'*');
        if (!empty($workerPidsInRedis)) {
            foreach ($workerPidsInRedis as $workerPidKey){
                $workerPids[] = intval( str_replace( self::worker_status_monitoring_key_prefix , '' ,$workerPidKey ) );
            }
        }
        return $workerPids;
    }
453735
def threads_list(io_handler, max_depth=1):
        
        # Normalize maximum depth
        try:
            max_depth = int(max_depth)
            if max_depth < 1:
                max_depth = None
        except (ValueError, TypeError):
            max_depth = None

        # pylint: disable=W0212
        try:
            # Extract frames
            frames = sys._current_frames()

            # Get the thread ID -> Thread mapping
            names = threading._active.copy()
        except AttributeError:
            io_handler.write_line("sys._current_frames() is not available.")
            return

        # Sort by thread ID
        thread_ids = sorted(frames.keys())
        lines = []
        for thread_id in thread_ids:
            # Get the corresponding stack
            stack = frames[thread_id]

            # Try to get the thread name
            try:
                name = names[thread_id].name
            except KeyError:
                name = "<unknown>"

            # Construct the code position
            lines.append("Thread ID: {0} - Name: {1}".format(thread_id, name))
            lines.append("Stack Trace:")

            trace_lines = []
            depth = 0
            frame = stack
            while frame is not None and (
                max_depth is None or depth < max_depth
            ):
                # Store the line information
                trace_lines.append(format_frame_info(frame))

                # Previous frame...
                frame = frame.f_back
                depth += 1

            # Reverse the lines
            trace_lines.reverse()

            # Add them to the printed lines
            lines.extend(trace_lines)
            lines.append("")

        lines.append("")

        # Sort the lines
        io_handler.write("\n".join(lines))