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
pull/443/head
Simon Willison 2019-04-21 12:02:24 -07:00
rodzic 11b352b4d5
commit bac4e01f40
1 zmienionych plików z 4 dodań i 2 usunięć

Wyświetl plik

@ -152,8 +152,10 @@ def sqlite_timelimit(conn, ms):
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):