From 20d29a96b871cffdd34a65f5823e8d27fb6233d5 Mon Sep 17 00:00:00 2001 From: Matthew Ball Date: Sun, 28 Jun 2026 12:07:45 -0700 Subject: [PATCH] remove dead code time_buffer.py no import of timed_buffer are found or used in Texera --- .../core/util/console_message/timed_buffer.py | 45 ------------------- 1 file changed, 45 deletions(-) delete mode 100644 amber/src/main/python/core/util/console_message/timed_buffer.py diff --git a/amber/src/main/python/core/util/console_message/timed_buffer.py b/amber/src/main/python/core/util/console_message/timed_buffer.py deleted file mode 100644 index 59369f16b21..00000000000 --- a/amber/src/main/python/core/util/console_message/timed_buffer.py +++ /dev/null @@ -1,45 +0,0 @@ -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -from datetime import datetime -from typing import Tuple, List, Iterator - -from proto.org.apache.texera.amber.engine.architecture.worker import ( - PythonConsoleMessageV2, -) - - -class TimedBuffer: - def __init__(self, max_message_num=10, max_flush_interval_in_ms=500): - self._max_message_num = max_message_num - self._max_flush_interval_in_ms = max_flush_interval_in_ms - self._buffer: List[Tuple[datetime, str]]() = list() - self._last_output_time = datetime.now() - - def add(self, console_message: PythonConsoleMessageV2) -> None: - self._buffer.append(console_message) - - def get(self, flush=False) -> Iterator[PythonConsoleMessageV2]: - if ( - flush - or len(self._buffer) >= self._max_message_num - or (datetime.now() - self._last_output_time).seconds - >= self._max_flush_interval_in_ms / 1000 - ): - self._last_output_time = datetime.now() - yield from self._buffer - self._buffer.clear()