Skip to content

Commit c6066dd

Browse files
authored
[sqlite] Mitigate the database locked problem for skylet config (skypilot-org#1509)
* Reorder conn.commit and cursor.close * WAL mode * linting
1 parent 742c1dc commit c6066dd

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

sky/skylet/configs.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@
1313
def _safe_cursor():
1414
"""A newly created, auto-commiting, auto-closing cursor."""
1515
conn = sqlite3.connect(_DB_PATH)
16+
# Use WAL mode to avoid locking problem in #1507.
17+
# Reference: https://stackoverflow.com/a/39265148
18+
conn.execute('PRAGMA journal_mode=WAL')
1619
cursor = conn.cursor()
1720
try:
1821
yield cursor

0 commit comments

Comments
 (0)