Run a daemon thread that requests and
    donates a token every `interval` seconds.
500115
def gcommer_donate_threaded(interval=5, region='EU-London', mode=None):
    
    def donate_thread():
        while 1:
            gcommer_donate(*find_server(region, mode))
            time.sleep(interval)

    Thread(target=donate_thread, daemon=True).start()
985215
def run_thread(self):
        """"""
        self._run_thread = True
        self._thread.setDaemon(True)
        self._thread.start()
891878
def start(self, daemon=True):
        
        if self._run_lock.acquire(False):
            try:
                # there is a short race window in which `start` release the lock,
                # but `run` has not picked it up yet, but the thread exists anyway
                if self._run_thread is None:
                    self._run_thread = threading.Thread(target=self._run_in_thread)
                    self._run_thread.daemon = daemon
                    self._run_thread.start()
            finally:
                self._run_lock.release()
1039857
def start(self) -> None:
        """"""
        # Looking up the IOLoop here allows to first instantiate the
        # PeriodicCallback in another thread, then start it using
        # IOLoop.add_callback().
        self.io_loop = IOLoop.current()
        self._running = True
        self._next_timeout = self.io_loop.time()
        self._schedule_next()
662830
def run_updater_in_background(self):
        
        thread = threading.Thread(target=self.updater_loop())
        thread.daemon = True
        thread.start()
152401
def on_open(self, ws):
        """"""
        def keep_alive(interval):
            while True:
                time.sleep(interval)
                self.ping()

        start_new_thread(keep_alive, (self.keep_alive_interval, ))
63628
def set_keepalive(self, interval):
        
        pinger = functools.partial(self.ping, 'keep-alive')
        self.reactor.scheduler.execute_every(period=interval, func=pinger)
635989
def process_request_thread(self, mainthread):
        """"""
        life_time   = time.time()
        nb_requests = 0

        while not mainthread.killed():
            if self.max_life_time > 0:
                if (time.time() - life_time) >= self.max_life_time:
                    mainthread.add_worker(1)
                    return
                try:
                    SocketServer.ThreadingTCPServer.process_request_thread(self, *self.requests.get(True, 0.5))
                except Queue.Empty:
                    continue
            else:
                SocketServer.ThreadingTCPServer.process_request_thread(self, *self.requests.get())

            LOG.debug("nb_requests: %d, max_requests: %d", nb_requests, self.max_requests)
            nb_requests += 1

            if self.max_requests > 0 and nb_requests >= self.max_requests:
                mainthread.add_worker(1)
                return
1299095
def run(self):
        """"""
        self.state = True
        self.hm.KeyAll = self.handler
        self.hm.HookKeyboard()
        while self.state:
            time.sleep(0.01)
            pythoncom.PumpWaitingMessages()
703392
def request_finished(key):
    
    with event_lock:
        threads[key] = threads[key][1:]

        if threads[key]:
            threads[key][0].run()
816361
def RunAsync(self):
    """"""
    self.running_thread = threading.Thread(
        name=self.thread_name, target=self._RunLoop)
    self.running_thread.daemon = True
    self.running_thread.start()
    return self.running_thread
1251200
def run(self):
        """"""
        while not self._finished.isSet():
            self._func(self._reference)
            self._finished.wait(self._func._interval / 1000.0)
1076288
def async_run(self, keyword, *args, **kwargs):
        '''  '''
        handle = self._last_thread_handle
        thread = self._threaded(keyword, *args, **kwargs)
        thread.start()
        self._thread_pool[handle] = thread
        self._last_thread_handle += 1
        return handle
1306516
def join_thread(thr):
    # type: (threading.Thread) -> None
    
    if on_python2():
        while True:
            thr.join(timeout=1)
            if not thr.isAlive():
                break
    else:
        thr.join()
55193
def run(self):
        """"""
        ret = eventlet.spawn(self.context(self.func))
        eventlet.sleep(self.seconds)
        try:
            ret.wait()
        except Exception:  # pylint: disable=broad-except
            traceback.print_exc()
        self.thread = eventlet.spawn(self.run)
1366942
def run_on(*, event: str):
        """"""

        def decorator(callback):
            @functools.wraps(callback)
            def decorator_wrapper():
                RTMClient.on(event=event, callback=callback)

            return decorator_wrapper()

        return decorator
371792
def start_monitoring(seconds_frozen=SECONDS_FROZEN,
                     test_interval=TEST_INTERVAL):
    
    
    thread = StoppableThread(target=monitor, args=(seconds_frozen,
                                                   test_interval))
    thread.daemon = True
    thread.start()
    return thread