Joins the thread.

        Args:
          self (ThreadReturn): the ``ThreadReturn`` instance
          args: optional list of arguments
          kwargs: optional key-word arguments

        Returns:
          The return value of the exited thread.
551027
def join(self, *args, **kwargs):
        
        super(ThreadReturn, self).join(*args, **kwargs)
        return self._return
629868
def join(self, timeout=None):
        
        rv = self.thread.join(timeout)
        if self.err:
            raise self.err
        return self.val
1306232
def _enable_thread_pool(func):
    

    @functools.wraps(func)
    def wrapper(*args, **kwargs):
        self = args[0]
        if self.enable_thread_pool and hasattr(self, 'thread_pool'):
            future = self.thread_pool.submit(func, *args, **kwargs)
            is_async = kwargs.get('is_async')
            if is_async is None or not is_async:
                timeout = kwargs.get('timeout')
                if timeout is None:
                    timeout = 2
                try:
                    result = future.result(timeout=timeout)
                except TimeoutError as e:
                    self.logger.exception(e)
                    result = None
                return result
            return future
        else:
            return func(*args, **kwargs)

    return wrapper
1200886
def join(self):
        
        LOG.debug("OplogThread: exiting due to join call.")
        self.running = False
        threading.Thread.join(self)
437508
def request(self, *args, **kwargs):
        
        func = partial(super().request, *args, **kwargs)
        return self.loop.run_in_executor(self.thread_pool, func)
1194043
def runQueryWithRetry(self, *args, **kw):
        

        def runQuery(txn, *args, **kw):
            txn.execute(*args, **kw)
            return txn.fetchall()

        return self.runInteractionWithRetry(runQuery, *args, **kw)
291821
def wait(self):
        
        self.thread.join()
        if self.error is not None:
            return self.error
        return self.result
1074316
def connect(cls, *args, **kwargs):
        
        loop = kwargs.get('loop')
        if loop is None:
            loop = trollius.get_event_loop()
        future = trollius.Future(loop=loop)

        def callback(arg):
            if not future.done():
                if isinstance(arg, Exception):
                    loop.call_soon_threadsafe(future.set_exception, arg)
                else:
                    loop.call_soon_threadsafe(future.set_result, arg)

        stream = cls(callback, *args, **kwargs)
        yield From(future)
        raise Return(stream)
1053973
def start_thread(self, target, args=(), kwargs=None, priority=0):
        
        return self.add_task(target, args, kwargs, priority)
363450
def default_create_thread(callback):
    
    thread = threading.Thread(None, callback)
    thread.daemon = True  # Don't let thread prevent termination
    thread.start()
    return thread
686648
public static <R> R runAndReturn(Runnable runnable,
            Supplier<R> returnSupplier) {
        runnable.run();
        return returnSupplier.get();
    }
37309
def close(self):
        
        if self._closed:
            return defer.succeed(None)

        def ok(_):
            self._closed = True
        return self.__flush().addCallback(ok)
1236181
def Join(self):
    """"""

    for _ in range(self.JOIN_TIMEOUT_DECISECONDS):
      if self._queue.empty() and not self.busy_threads:
        return
      time.sleep(0.1)

    raise ValueError("Timeout during Join() for threadpool %s." % self.name)
154816
def join(self, timeout_s=None):
    
    if not self.thread:
      return False
    self.thread.join(timeout_s)
    return self.running
299344
def bg_thread(func):
    
    @functools.wraps(func)
    def wrapper(*args, **kwargs):
        p = threading.Thread(target=func, args=args, kwargs=kwargs)
        p.start()
    return wrapper
198730
def __postCallAction(self, event):
        
        aThread = event.get_thread()
        retval  = self._get_return_value(aThread)
        self.__callHandler(self.__postCB, event, retval)
518209
def open(self):
        
        with self._lock:
            if self._thread_will_exit:
                # If the background thread has read self._stopped as True
                # there is a chance that it has not yet exited. The call to
                # join should not block indefinitely because there is no
                # other work done outside the while loop in self._run.
                try:
                    self._thread.join()
                except ReferenceError:
                    # Thread terminated.
                    pass
            self._thread_will_exit = False
            self._stopped = False
        started = False
        try:
            started = self._thread and self._thread.is_alive()
        except ReferenceError:
            # Thread terminated.
            pass

        if not started:
            thread = threading.Thread(target=self._run, name=self._name)
            thread.daemon = True
            self._thread = weakref.proxy(thread)
            _register_executor(self)
            thread.start()