-
-
Notifications
You must be signed in to change notification settings - Fork 685
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
db.execute_write_fn(create_tables, block=True) hangs a thread if connection fails #935
Comments
The bug is here: datasette/datasette/database.py Lines 89 to 100 in 13b3b51
If
|
The easiest way to recreate this is to attempt a write against an immutable database, which triggers this assertion error: datasette/datasette/database.py Lines 47 to 55 in 13b3b51
|
This implementation seems to fix it, need to work out how to test though. diff --git a/datasette/database.py b/datasette/database.py
index ffa7a79..7ba1456 100644
--- a/datasette/database.py
+++ b/datasette/database.py
@@ -89,14 +89,22 @@ class Database:
def _execute_writes(self):
# Infinite looping thread that protects the single write connection
# to this database
- conn = self.connect(write=True)
+ conn_exception = None
+ conn = None
+ try:
+ conn = self.connect(write=True)
+ except Exception as e:
+ conn_exception = e
while True:
task = self._write_queue.get()
- try:
- result = task.fn(conn)
- except Exception as e:
- print(e)
- result = e
+ if conn_exception is not None:
+ result = conn_exception
+ else:
+ try:
+ result = task.fn(conn)
+ except Exception as e:
+ print(e)
+ result = e
task.reply_queue.sync_q.put(result)
async def execute_fn(self, fn): |
Discovered in simonw/latest-datasette-with-all-plugins#3 (comment)
The text was updated successfully, but these errors were encountered: