From 71a2802e49347045033e74e38aecfee1dd37f58e Mon Sep 17 00:00:00 2001 From: ideal Date: Mon, 23 Mar 2026 15:39:54 +0800 Subject: [PATCH] Fix potential OSError when removing log file on FUSE device --- loguru/_file_sink.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/loguru/_file_sink.py b/loguru/_file_sink.py index 25d63f94..925191c3 100644 --- a/loguru/_file_sink.py +++ b/loguru/_file_sink.py @@ -64,7 +64,15 @@ def compression(path_in, ext, compress_function): renamed_path = generate_rename_path(root, ext_before + ext, creation_time) os.rename(path_out, renamed_path) compress_function(path_in, path_out) - os.remove(path_in) + if os.path.exists(path_in): + # In some cases when we write logs to directory mounted with + # FUSE device using OSS (or AWS S3) + Fluid, here we may encounter: + # OSError: [Errno 34] Numerical result out of range, + # but the log file is removed successfully actually + try: + os.remove(path_in) + except OSError: + pass class Retention: