]> kaliko git repositories - mpd-sima.git/blobdiff - sima/utils/filelock.py
Catch forgotten exception in mpdclient (Closes #59)
[mpd-sima.git] / sima / utils / filelock.py
index 959f6362d977503718d6c6e37c3addbcba6d771b..b5c51b6765f17d2f247693529157e07c09bc7aab 100644 (file)
@@ -1,7 +1,7 @@
 # -*- coding: utf-8 -*-
 
 # Copyright (c) 2009 Evan Fosmark
-# Copyright (c) 2014 kaliko <kaliko@azylum.org>
+# Copyright (c) 2014, 2021 kaliko <kaliko@azylum.org>
 #
 #   This program is free software: you can redistribute it and/or modify
 #   it under the terms of the GNU General Public License as published by
@@ -47,7 +47,7 @@ class FileLock:
         self.filedsc = None
         self.is_locked = False
         dirname = os.path.dirname(file_name)
-        self.lockfile = os.path.join(dirname, '{0}.lock'.format(file_name))
+        self.lockfile = os.path.join(dirname, 'f{file_name}.lock')
         self.file_name = file_name
         self.timeout = timeout
         self.delay = delay
@@ -65,7 +65,7 @@ class FileLock:
                 if err.errno != errno.EEXIST:
                     raise
                 if (time.time() - start_time) >= self.timeout:
-                    raise FileLockException('Timeout occured.')
+                    raise FileLockException('Timeout occured.') from err
                 time.sleep(self.delay)
         self.is_locked = True
 
@@ -84,7 +84,7 @@ class FileLock:
             self.acquire()
         return self
 
-    def __exit__(self, type, value, traceback):
+    def __exit__(self, ex_type, ex_value, ex_traceback):
         """end of the with statement
         """
         if self.is_locked: