Skip to content

Commit bac4e01

Browse files
committed
Ensure sqlite_timelimit correctly clears handler
If an error occurred inside the block the progress handler (used to enforce a time limit) was not being correctly cleared, resulting in timeout errors potentially occurring during subsequent SQL queries. The fix is described here: https://docs.python.org/3/library/contextlib.html#contextlib.contextmanager
1 parent 11b352b commit bac4e01

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

‎datasette/utils.py‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,8 +152,10 @@ def handler():
152152
return 1
153153

154154
conn.set_progress_handler(handler, n)
155-
yield
156-
conn.set_progress_handler(None, n)
155+
try:
156+
yield
157+
finally:
158+
conn.set_progress_handler(None, n)
157159

158160

159161
class InvalidSql(Exception):

0 commit comments

Comments
 (0)