From bf2a10f88b333046067add01596f903c13bd4460 Mon Sep 17 00:00:00 2001 From: Athanasius Date: Mon, 18 Jan 2021 20:59:23 +0000 Subject: [PATCH] Catch only 'Exception' off mvscrt.locking() * It *should* only be a PermissionError, although the docs actually say the 'higher' OSError. This way we will always catch whatever it is. * The print uses {e!r} so as to make it explicit what the type of the exception is. --- EDMarketConnector.py | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/EDMarketConnector.py b/EDMarketConnector.py index ad9e7847..27140c8f 100755 --- a/EDMarketConnector.py +++ b/EDMarketConnector.py @@ -65,16 +65,8 @@ if __name__ == "__main__": try: msvcrt.locking(journal_dir_lockfile.fileno(), msvcrt.LK_NBLCK, 4096) - except PermissionError as e: - print(f"PermissionError: Couldn't lock journal directory \"{journal_dir}\", assuming another process running\n{e}") - return False - - except OSError as e: - print(f"OSError: Couldn't lock journal directory \"{journal_dir}\", assuming another process running\n{e}") - return False - except Exception as e: - print(f"other Exception: Couldn't lock journal directory \"{journal_dir}\", assuming another process running\n{e}") + print(f"Exception: Couldn't lock journal directory \"{journal_dir}\", assuming another process running\n{e!r}") return False journal_dir_lockfile.write(f"Path: {journal_dir}\nPID: {os_getpid()}\n")