Merge pull request #1874 from antmicro/fix-race-condition
Fix race condition
diff --git a/.github/workflows/database.yml b/.github/workflows/database.yml
index 924cc6e..1bf9403 100644
--- a/.github/workflows/database.yml
+++ b/.github/workflows/database.yml
@@ -4,7 +4,7 @@
schedule:
- cron: '0 0 * * *'
-name: CI Build
+name: Database
jobs:
BuildDatabase:
diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml
index 7c5f3f1..2364ad6 100644
--- a/.github/workflows/tests.yml
+++ b/.github/workflows/tests.yml
@@ -4,7 +4,7 @@
schedule:
- cron: '0 0 * * *'
-name: CI Build
+name: Tests
jobs:
diff --git a/utils/dbfixup.py b/utils/dbfixup.py
index a08bf5a..0e3310d 100755
--- a/utils/dbfixup.py
+++ b/utils/dbfixup.py
@@ -536,8 +536,10 @@
changes += new_changes
with open(fn_out, "w") as f:
+ util.lock_file(f, 10)
for line in sorted(lines):
print(line, file=f)
+ util.unlock_file(f)
if changes is not None:
seg_files += 1
diff --git a/utils/sort_db.py b/utils/sort_db.py
index 7256b45..2d09a86 100755
--- a/utils/sort_db.py
+++ b/utils/sort_db.py
@@ -65,6 +65,7 @@
import json
import utils.xjson as xjson
import utils.cmp as cmp
+from prjxray.util import lock_file, unlock_file
def split_all(s, chars):
@@ -344,9 +345,11 @@
# copy[i], tosort[i])
with open(pathname, 'w') as f:
+ lock_file(f, 10)
for _, l in tosort:
f.write(l)
f.write('\n')
+ unlock_file(f)
return True
@@ -405,8 +408,10 @@
rows.sort(key=lambda i: i[0])
with open(n, 'w') as f:
+ lock_file(f, 10)
for l in rows:
f.write(l[-1])
+ unlock_file(f)
return True