Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
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
  • Loading branch information
simonw committed Apr 21, 2019
1 parent 11b352b commit bac4e01
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions datasette/utils.py
Expand Up @@ -152,8 +152,10 @@ def handler():
return 1

conn.set_progress_handler(handler, n)
yield
conn.set_progress_handler(None, n)
try:
yield
finally:
conn.set_progress_handler(None, n)


class InvalidSql(Exception):
Expand Down

0 comments on commit bac4e01

Please sign in to comment.