From b9ad6a3bac4b0ec05822e3ff6b4c9790e23570fc Mon Sep 17 00:00:00 2001 From: lakshyacis Date: Tue, 22 Oct 2019 19:54:20 +0530 Subject: [PATCH] singleinstance quality fixes --- src/singleinstance.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/singleinstance.py b/src/singleinstance.py index 03bda504..d0a0871c 100644 --- a/src/singleinstance.py +++ b/src/singleinstance.py @@ -16,7 +16,7 @@ except ImportError: pass -class singleinstance: +class singleinstance(object): """ Implements a single instance application by creating a lock file at appdata. @@ -40,6 +40,7 @@ class singleinstance: atexit.register(self.cleanup) def lock(self): + """Obtain single instance lock""" if self.lockPid is None: self.lockPid = os.getpid() if sys.platform == 'win32': @@ -52,8 +53,7 @@ class singleinstance: self.lockfile, os.O_CREAT | os.O_EXCL | os.O_RDWR | os.O_TRUNC ) - except OSError: - type, e, tb = sys.exc_info() + except OSError as e: if e.errno == 13: print( 'Another instance of this application' @@ -84,6 +84,7 @@ class singleinstance: self.fp.flush() def cleanup(self): + """Release single instance lock""" if not self.initialized: return if self.daemon and self.lockPid == os.getpid(): @@ -94,7 +95,7 @@ class singleinstance: os.close(self.fd) else: fcntl.lockf(self.fp, fcntl.LOCK_UN) - except Exception, e: + except Exception: pass return