From db46676dec24133602bc1c32308c9e78947e834a Mon Sep 17 00:00:00 2001 From: Serene-Arc Date: Tue, 27 Apr 2021 12:54:30 +1000 Subject: [PATCH] Catch error when logfile accessed concurrently --- bdfr/downloader.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/bdfr/downloader.py b/bdfr/downloader.py index 48c4234..5acb7de 100644 --- a/bdfr/downloader.py +++ b/bdfr/downloader.py @@ -203,7 +203,13 @@ class RedditDownloader: backupCount=backup_count, ) if log_path.exists(): - file_handler.doRollover() + try: + file_handler.doRollover() + except PermissionError as e: + logger.critical( + 'Cannot rollover logfile, make sure this is the only ' + 'BDFR process or specify alternate logfile location') + raise formatter = logging.Formatter('[%(asctime)s - %(name)s - %(levelname)s] - %(message)s') file_handler.setFormatter(formatter) file_handler.setLevel(0)