From b1385e92166649f1b0e9d86c1ef2cfb0e0537c35 Mon Sep 17 00:00:00 2001 From: SkanderBM Date: Sun, 6 Dec 2020 22:04:56 +0100 Subject: [PATCH] ensure if the open file have the good link. --- circus/stream/file_stream.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/circus/stream/file_stream.py b/circus/stream/file_stream.py index eb1f8ac3c..eea7e5220 100644 --- a/circus/stream/file_stream.py +++ b/circus/stream/file_stream.py @@ -105,6 +105,8 @@ def __call__(self, data): if self._should_rollover(data['data']): self._do_rollover() + self._ensure_file_exists() + self.write_data(data) def _do_rollover(self): @@ -145,6 +147,14 @@ def _should_rollover(self, raw_data): return 1 return 0 + def _ensure_file_exists(self): + if self._file: + file_link = os.fstat(self._file.fileno()).st_nlink + if file_link == 0: + self._file.close() + self._file = self._open() + + class WatchedFileStream(_FileStreamBase): def __init__(self, filename=None, time_format=None, **kwargs):