yandextank/plugins/Bfg/worker.py
def _green_worker(self):
        """
        A worker that does actual jobs
        """
        while not self.quit.is_set():
            try:
                task = self.green_queue.get(timeout=1)

                timestamp, missile, marker = task
                planned_time = self.start_time + (timestamp / 1000.0)
                delay = planned_time - time.time()

                if delay > 0:
                    time.sleep(delay)

                try:
                    with self.instance_counter.get_lock():
                        self.instance_counter.value += 1

                    self.gun.shoot(missile, marker)
                finally:
                    with self.instance_counter.get_lock():
                        self.instance_counter.value -= 1

                    self._free_threads_count += 1

            except (KeyboardInterrupt, SystemExit):
                break
            except Empty:
                continue
            except Full:
                logger.warning("Couldn't put to result queue because it's full")
            except Exception:
                logger.exception("Bfg shoot exception")
def _green_worker(self):
        """
        A worker that does actual jobs
        """
        while not self.quit.is_set():
            try:
                task = self.green_queue.get(timeout=1)

                timestamp, missile, marker = task
                planned_time = self.start_time + (timestamp / 1000.0)
                delay = planned_time - time.time()

                if delay > 0:
                    time.sleep(delay)

                try:
                    with self.instance_counter.get_lock():
                        self.instance_counter.value += 1

                    self.gun.shoot(missile, marker)
                finally:
                    with self.instance_counter.get_lock():
                        self.instance_counter.value -= 1

                    self._free_threads_count += 1

            except (KeyboardInterrupt, SystemExit):
                break
            except Empty:
                continue
            except Full:
                logger.warning("Couldn't put to result queue because it's full")
            except Exception:
                logger.exception("Bfg shoot exception")
def _green_worker ( self ) : while not self . quit . is_set ( ) : try : task = self . green_queue . get ( timeout = 1 ) timestamp , missile , marker = task planned_time = self . start_time + ( timestamp / 1000.0 ) delay = planned_time - time . time ( ) if delay > 0 : time . sleep ( delay ) try : with self . instance_counter . get_lock ( ) : self . instance_counter . value += 1 self . gun . shoot ( missile , marker ) finally : with self . instance_counter . get_lock ( ) : self . instance_counter . value -= 1 self . _free_threads_count += 1 except ( KeyboardInterrupt , SystemExit ) : break except Empty : continue except Full : logger . warning ( "Couldn't put to result queue because it's full" ) except Exception : logger . exception ( "Bfg shoot exception" )
A worker that does actual jobs
A worker that does actual jobs