List the currently running python threads.

    Returns:
      A list of the inferior's thread idents, or None if the debugger is not
      attached to any process.
436067
def ListThreads(self):
    
    if self.inferior.is_running:
      return self.inferior.threads
    logging.error('Not attached to any process.')
    return []
592881
static ThreadTrace getThreadTrace() {
    ThreadTrace t = traces.get();
    if (t == null) {
      t = new ThreadTrace();
      t.prettyPrint = defaultPrettyPrint;
      traces.set(t);
    }
    return t;
  }
695131
def monitor(seconds_frozen, test_interval):
    
    current_thread = threading.current_thread()
    hanging_threads = set()
    old_threads = {}  # Threads found on previous iteration.

    while not current_thread.is_stopped():
        new_threads = get_current_frames()

        # Report died threads.
        for thread_id in old_threads.keys():
            if thread_id not in new_threads and thread_id in hanging_threads:
                log_died_thread(thread_id)

        # Process live threads.
        time.sleep(test_interval/1000.)
        now = time.time()
        then = now - seconds_frozen
        for thread_id, thread_data in new_threads.items():
            # Don't report the monitor thread.
            if thread_id == current_thread.ident:
                continue
            frame = thread_data['frame']
            # If thread is new or it's stack is changed then update time.
            if (thread_id not in old_threads or
                    frame != old_threads[thread_id]['frame']):
                thread_data['time'] = now
                # If the thread was hanging then report awaked thread.
                if thread_id in hanging_threads:
                    hanging_threads.remove(thread_id)
                    log_awaked_thread(thread_id)
            else:
                # If stack is not changed then keep old time.
                last_change_time = old_threads[thread_id]['time']
                thread_data['time'] = last_change_time
                # Check if this is a new hanging thread.
                if (thread_id not in hanging_threads and
                        last_change_time < then):
                    # Gotcha!
                    hanging_threads.add(thread_id)
                    # Report the hanged thread.
                    log_hanged_thread(thread_id, frame)
        old_threads = new_threads
528155
private Thread[] enumerateThreads() {
        boolean fits = false;
        int inc = 50;
        Thread[] threads = null;
        int nrThreads = 0;
        while (!fits) {
            try {
                threads = new Thread[Thread.activeCount()+inc];
                nrThreads = Thread.enumerate(threads);
                fits = true;
            } catch (ArrayIndexOutOfBoundsException exp) {
                inc += 50;
            }
        }
        // Trim array
        Thread ret[] = new Thread[nrThreads];
        System.arraycopy(threads,0,ret,0,nrThreads);
        return ret;
    }
222922
def checkForFinishedThreads(self):
        ''
        for t in self.unfinishedThreads:
            if not t.is_alive():
                t.endTime = time.process_time()
                if getattr(t, 'status', None) is None:
                    t.status = 'ended'
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)
1051744
def thread_details(io_handler, thread_id, max_depth=0):
        
        # 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:
            # Get the stack
            thread_id = int(thread_id)
            stack = sys._current_frames()[thread_id]
        except KeyError:
            io_handler.write_line("Unknown thread ID: {0}", thread_id)
        except ValueError:
            io_handler.write_line("Invalid thread ID: {0}", thread_id)
        except AttributeError:
            io_handler.write_line("sys._current_frames() is not available.")
        else:
            # Get the name
            try:
                name = threading._active[thread_id].name
            except KeyError:
                name = "<unknown>"

            lines = [
                "Thread ID: {0} - Name: {1}".format(thread_id, name),
                "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("")
            io_handler.write("\n".join(lines))
926143
def dump_stacks(self):
        '''
        
        '''

        dump = []

        # threads
        threads = dict([(th.ident, th.name)
                            for th in threading.enumerate()])

        for thread, frame in sys._current_frames().items():
            if thread not in threads: continue
            dump.append('Thread 0x%x (%s)\n' % (thread, threads[thread]))
            dump.append(''.join(traceback.format_stack(frame)))
            dump.append('\n')

        return ''.join(dump)
699472
def codingthreads(self):
        
        printtime('Extracting CDS features', self.start)
        # Create and start threads
        for i in range(self.cpus):
            # Send the threads to the appropriate destination function
            threads = Thread(target=self.codingsequences, args=())
            # Set the daemon to true - something to do with thread management
            threads.setDaemon(True)
            # Start the threading
            threads.start()
        for sample in self.runmetadata.samples:
            self.codingqueue.put(sample)
        self.codingqueue.join()
        # Create CDS files and determine gene presence/absence
        self.corethreads()
446649
def executions(self):
        
        if self._executions is None:
            self._executions = ExecutionList(self._version, flow_sid=self._solution['sid'], )
        return self._executions
730699
def is_mainthread(thread=None):
    '''
    '''
    thread = thread if thread is not None else current_thread()
    return isinstance(thread, threading._MainThread)
709326
def threads_bt(self):
        """"""
        import threading
        import traceback

        threads = {}
        for thread in threading.enumerate():
            frames = sys._current_frames().get(thread.ident)
            if frames:
                stack = traceback.format_stack(frames)
            else:
                stack = []
            threads[thread] = "".join(stack)
        return flask.render_template("gourde/threads.html", threads=threads)
594007
def scan_threads=(threads)
      scan_threads = REXML::XPath.first(@xml, 'ScanTemplate/General/scanThreads')
      scan_threads.text = threads.to_s
    end
930291
def list(self, sort=False):
        
        prs = self._processors.values()
        if sort:
            return sorted(prs, key=operator.methodcaller("cid"))

        return prs
1041810
public int getIdleThreads()
   {
      if (executor instanceof ThreadPoolExecutor)
      {
         final ThreadPoolExecutor tpe = (ThreadPoolExecutor)executor;
         return tpe.getPoolSize() - tpe.getActiveCount();
      }
      return -1;
   }
466858
def print_all(self, out=sys.stdout):
        
        THREAD_FUNC_NAME_LEN = 25
        THREAD_NAME_LEN = 13
        THREAD_ID_LEN = 15
        THREAD_SCHED_CNT_LEN = 10

        out.write(CRLF)
        out.write("name           tid              ttot      scnt")
        out.write(CRLF)
        for stat in self:
            out.write(StatString(stat.name).ltrim(THREAD_NAME_LEN))
            out.write(" " * COLUMN_GAP)
            out.write(StatString(stat.id).rtrim(THREAD_ID_LEN))            
            out.write(" " * COLUMN_GAP)
            out.write(StatString(_fft(stat.ttot)).rtrim(TIME_COLUMN_LEN))
            out.write(" " * COLUMN_GAP)
            out.write(StatString(stat.sched_count).rtrim(THREAD_SCHED_CNT_LEN))
            out.write(CRLF)
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