Take obj from queue, but will give up when the thread is stopped
965013
def queue_get_stoppable(self, q):
        
        while not self.stopped():
            try:
                return q.get(timeout=5)
            except queue.Empty:
                pass
1271203
final boolean abort(boolean removeFromQueue, Throwable cause) {
        if (removeFromQueue && executor.queue.remove(this))
            executor.maxQueueSizeConstraint.release();
        if (nsAcceptEnd == nsAcceptBegin - 1) // currently unset
            nsRunEnd = nsQueueEnd = nsAcceptEnd = System.nanoTime();
        boolean aborted = result.compareAndSet(state, cause);
        if (aborted)
            try {
                state.releaseShared(ABORTED);
                if (nsQueueEnd == nsAcceptBegin - 2) // currently unset
                    nsRunEnd = nsQueueEnd = System.nanoTime();
                if (callback != null)
                    callback.onEnd(task, this, null, true, 0, cause);
            } finally {
                if (latch != null)
                    latch.countDown();
                if (cancellableStage != null) {
                    if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled())
                        Tr.debug(this, tc, "completion stage to complete exceptionally: " + cancellableStage);
                    cancellableStage.completeExceptionally(cause);
                }
            }
        else {
            // Prevent premature return from abort that would allow subsequent getState() to indicate
            // that the task is still in SUBMITTED state.
            while (state.get() < RUNNING)
                Thread.yield();
        }
        return aborted;
    }
561688
protected final void finish(Thread t) {
    if (t == null) {
      // nothing to terminate
      return;
    }
    try {
      StreamPumper s = null;
      if (t instanceof ThreadWithPumper) {
        s = ((ThreadWithPumper) t).getPumper();
      }
      if (s != null && s.isFinished()) {
        return;
      }
      if (!t.isAlive()) {
        return;
      }

      if (s != null && !s.isFinished()) {
        s.stop();
      }
      t.join(JOIN_TIMEOUT);
      while ((s == null || !s.isFinished()) && t.isAlive()) {
        t.interrupt();
        t.join(JOIN_TIMEOUT);
      }
    } catch (InterruptedException e) {
      // ignore
    }
  }
1025635
def queue(self, value):
		
		if not isinstance(value, Queue):
			raise TypeError("queue is not a Queue object")
		self._queue = value
1261950
def _remove(self, obj):
        """"""
        for idx, item in enumerate(self._queue):
            if item == obj:
                del self._queue[idx]
                break
633945
def _on_run(self):
        '''  '''

        try:
            while True:
                try:
                    try:
                        cmd = self.cmdQueue.get(1, 0.1)
                    except _queue.Empty:
                        if self.killReceived:
                            try:
                                self.sock.shutdown(SHUT_WR)
                                self.sock.close()
                            except:
                                pass

                            return  # break if queue is empty and killReceived
                        else:
                            continue
                except:
                    # pydev_log.info('Finishing debug communication...(1)')
                    # when liberating the thread here, we could have errors because we were shutting down
                    # but the thread was still not liberated
                    return
                cmd.send(self.sock)

                if cmd.id == CMD_EXIT:
                    break
                if time is None:
                    break  # interpreter shutdown
                time.sleep(self.timeout)
        except Exception:
            GlobalDebuggerHolder.global_dbg.finish_debugging_session()
            if DebugInfoHolder.DEBUG_TRACE_LEVEL >= 0:
                pydev_log_exception()
388309
def pop(non_block=false)
      handle_interrupt do
        @mutex.synchronize do
          while true
            if @que.empty?
              if non_block
                raise ThreadError, "queue empty"
              else
                begin
                  @num_waiting += 1
                  @cond.wait @mutex
                ensure
                  @num_waiting -= 1
                end
              end
            else
              return @que.shift
            end
          end
        end
      end
    end
153579
def go(self):
        
        DEBUG and self._name and Log.note("GO! {{name|quote}}", name=self.name)

        if self._go:
            return

        with self.lock:
            if self._go:
                return
            self._go = True

        DEBUG and self._name and Log.note("internal GO! {{name|quote}}", name=self.name)
        jobs, self.job_queue = self.job_queue, None
        threads, self.waiting_threads = self.waiting_threads, None

        if threads:
            DEBUG and self._name and Log.note("Release {{num}} threads", num=len(threads))
            for t in threads:
                t.release()

        if jobs:
            for j in jobs:
                try:
                    j()
                except Exception as e:
                    Log.warning("Trigger on Signal.go() failed!", cause=e)
1241341
def thread_stopped(self):
		
		task = self.task()
		if isinstance(task, WStoppableTask) is True:
			task.stop()
1043236
def waitResult(self):
    
    self.thread.execute_queue.join()
    try:
      e = self.thread.exception_queue[threading.get_ident()].get_nowait()
    except queue.Empty:
      return self.thread.result_queue[threading.get_ident()].get_nowait()
    else:
      raise e
1201034
public static void wait(Object lock, long timeout) {
	try {
	    synchronized (lock) {
		lock.wait(timeout);
	    }
	}
	catch (InterruptedException e) {}
    }
1190395
def async_get(self, handle):
        '''  '''
        assert handle in self._thread_pool, 'Invalid async call handle'
        result = self._thread_pool[handle].result_queue.get()
        del self._thread_pool[handle]
        return result
798042
public static <E> E takeUninterruptibly(BlockingQueue<E> queue) {
    boolean interrupted = false;
    try {
      while (true) {
        try {
          return queue.take();
        } catch (InterruptedException e) {
          interrupted = true;
        }
      }
    } finally {
      if (interrupted) {
        Thread.currentThread().interrupt();
      }
    }
  }
59427
function () {
            this.__ending = true;
            var conn, fQueue = this.__freeObjects, count = this.count, ps = [];
            while ((conn = this.__freeObjects.dequeue()) !== undefined) {
                ps.push(this.closeConnection(conn));
            }
            var inUse = this.__inUseObjects;
            for (var i = inUse.length - 1; i >= 0; i--) {
                ps.push(this.closeConnection(inUse[i]));
            }
            this.__inUseObjects.length = 0;
            return new PromiseList(ps).promise();
        }
673348
def get(self, block=True, timeout=None):
        """"""
        return self._queue.get(block, timeout)
949123
public static void waitForDie(Thread thread) {
		boolean dead = false;
		do {
			try {
				thread.join();
				dead = true;
			} catch (InterruptedException e) {
				// ignore
			}
		} while (!dead);
	}
708621
def _wait_until(obj, att, desired, callback, interval, attempts, verbose,
        verbose_atts):
    
    if not isinstance(desired, (list, tuple)):
        desired = [desired]
    if verbose_atts is None:
        verbose_atts = []
    if not isinstance(verbose_atts, (list, tuple)):
        verbose_atts = [verbose_atts]
    infinite = (attempts == 0)
    attempt = 0
    start = time.time()
    while infinite or (attempt < attempts):
        try:
            # For servers:
            obj.get()
        except AttributeError:
            try:
                # For other objects that don't support .get()
                obj = obj.manager.get(obj.id)
            except AttributeError:
                # punt
                raise exc.NoReloadError("The 'wait_until' method is not "
                        "supported for '%s' objects." % obj.__class__)
        attval = getattr(obj, att)
        if verbose:
            elapsed = time.time() - start
            msgs = ["Current value of %s: %s (elapsed: %4.1f seconds)" % (
                    att, attval, elapsed)]
            for vatt in verbose_atts:
                vattval = getattr(obj, vatt, None)
                msgs.append("%s=%s" % (vatt, vattval))
            print(" ".join(msgs))
        if attval in desired:
            return obj
        time.sleep(interval)
        attempt += 1
    return obj