[damned-lies] Refs #146 - Remove the update lock after more than one day
- From: Claude Paroz <claudep src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [damned-lies] Refs #146 - Remove the update lock after more than one day
- Date: Sun, 21 Apr 2019 18:30:06 +0000 (UTC)
commit f72887545f3ae9d79ee9003092e982bb5add7720
Author: Claude Paroz <claude 2xlibre net>
Date: Sun Apr 21 20:28:10 2019 +0200
Refs #146 - Remove the update lock after more than one day
stats/models.py | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
---
diff --git a/stats/models.py b/stats/models.py
index 93c022e1..193188de 100644
--- a/stats/models.py
+++ b/stats/models.py
@@ -181,8 +181,12 @@ class ModuleLock:
os.mkdir(self.dirpath)
break
except FileExistsError:
- # Something is happening on the module, let's wait
- sleep(10)
+ if (datetime.now() - datetime.fromtimestamp(os.path.getctime(self.dirpath))).days > 1:
+ # After more than one day, something was blocked, force release the lock.
+ os.rmdir(self.dirpath)
+ else:
+ # Something is happening on the module, let's wait.
+ sleep(10)
def __exit__(self, *exc_info):
os.rmdir(self.dirpath)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]