def shutdown(): timeout_seconds = scout_config.value("shutdown_timeout_seconds") def callback(queue_size): if scout_config.value("shutdown_message_enabled"): print( # noqa: T001 ("Scout draining {queue_size} event{s} for up to" + " {timeout_seconds} seconds").format( queue_size=queue_size, s=("" if queue_size == 1 else "s"), timeout_seconds=timeout_seconds, ), file=sys.stderr, ) CoreAgentSocketThread.wait_until_drained(timeout_seconds=timeout_seconds, callback=callback)
def test_wait_until_drained_one_slow(socket): class SlowCommand(object): def message(self): time.sleep(0.05) return {} for _ in range(10): CoreAgentSocketThread.send(SlowCommand()) empty = CoreAgentSocketThread.wait_until_drained(timeout_seconds=0.05) assert not empty
def test_wait_until_drained_one_item(socket): CoreAgentSocketThread._command_queue.put(Command(), False) empty = CoreAgentSocketThread.wait_until_drained() assert empty
def test_wait_until_drained_empty(socket): empty = CoreAgentSocketThread.wait_until_drained() assert empty