Skip to content

Commit 884e079

Browse files
author
matdev83
committed
fix: Remove unsafe __del__ method
- Remove the __del__ method from �uffered_wire_capture_service.py to prevent potential memory leaks and resource locking issues during interpreter shutdown.
1 parent 2185748 commit 884e079

File tree

1 file changed

+0
-30
lines changed

1 file changed

+0
-30
lines changed

src/core/services/buffered_wire_capture_service.py

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -229,36 +229,6 @@ def __init__(self, config: AppConfig) -> None:
229229
if self._file_path:
230230
self._initialize()
231231

232-
def __del__(self) -> None:
233-
"""Cleanup resources when the instance is destroyed."""
234-
if (
235-
hasattr(self, "_flush_task")
236-
and self._flush_task
237-
and not self._flush_task.done()
238-
):
239-
import logging
240-
241-
def _can_write(handler: logging.Handler) -> bool:
242-
stream = getattr(handler, "stream", None)
243-
return stream is None or not getattr(stream, "closed", False)
244-
245-
def _safe_to_log() -> bool:
246-
try:
247-
handlers = set(logger.handlers)
248-
root = logging.getLogger()
249-
handlers.update(root.handlers)
250-
return all(_can_write(h) for h in handlers)
251-
except Exception:
252-
return False
253-
254-
if _safe_to_log():
255-
with contextlib.suppress(Exception):
256-
logger.warning(
257-
"BufferedWireCapture was garbage collected without being shut down. "
258-
"Call shutdown() to ensure data is flushed and tasks are cleaned up."
259-
)
260-
self.force_shutdown_sync()
261-
262232
def _initialize(self) -> None:
263233
"""Initialize the wire capture system."""
264234
if not self._file_path:

0 commit comments

Comments
 (0)