mirror of
https://github.com/simonw/datasette.git
synced 2025-12-10 16:51:24 +01:00
Rename InterruptedError => QueryInterrupted, closes #490
This commit is contained in:
parent
edb36629e7
commit
bd4dbc8519
7 changed files with 20 additions and 20 deletions
|
|
@ -26,7 +26,7 @@ from .renderer import json_renderer
|
||||||
from .database import Database
|
from .database import Database
|
||||||
|
|
||||||
from .utils import (
|
from .utils import (
|
||||||
InterruptedError,
|
QueryInterrupted,
|
||||||
Results,
|
Results,
|
||||||
escape_css_string,
|
escape_css_string,
|
||||||
escape_sqlite,
|
escape_sqlite,
|
||||||
|
|
@ -346,7 +346,7 @@ class Datasette:
|
||||||
)
|
)
|
||||||
try:
|
try:
|
||||||
results = await self.execute(database, sql, list(set(values)))
|
results = await self.execute(database, sql, list(set(values)))
|
||||||
except InterruptedError:
|
except QueryInterrupted:
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
for id, value in results:
|
for id, value in results:
|
||||||
|
|
@ -504,7 +504,7 @@ class Datasette:
|
||||||
truncated = False
|
truncated = False
|
||||||
except sqlite3.OperationalError as e:
|
except sqlite3.OperationalError as e:
|
||||||
if e.args == ("interrupted",):
|
if e.args == ("interrupted",):
|
||||||
raise InterruptedError(e, sql, params)
|
raise QueryInterrupted(e, sql, params)
|
||||||
if log_sql_errors:
|
if log_sql_errors:
|
||||||
print(
|
print(
|
||||||
"ERROR: conn={}, sql = {}, params = {}: {}".format(
|
"ERROR: conn={}, sql = {}, params = {}: {}".format(
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
from .utils import (
|
from .utils import (
|
||||||
InterruptedError,
|
QueryInterrupted,
|
||||||
detect_fts,
|
detect_fts,
|
||||||
detect_primary_keys,
|
detect_primary_keys,
|
||||||
detect_spatialite,
|
detect_spatialite,
|
||||||
|
|
@ -58,8 +58,8 @@ class Database:
|
||||||
).rows[0][0]
|
).rows[0][0]
|
||||||
counts[table] = table_count
|
counts[table] = table_count
|
||||||
# In some cases I saw "SQL Logic Error" here in addition to
|
# In some cases I saw "SQL Logic Error" here in addition to
|
||||||
# InterruptedError - so we catch that too:
|
# QueryInterrupted - so we catch that too:
|
||||||
except (InterruptedError, sqlite3.OperationalError):
|
except (QueryInterrupted, sqlite3.OperationalError):
|
||||||
counts[table] = None
|
counts[table] = None
|
||||||
if not self.is_mutable:
|
if not self.is_mutable:
|
||||||
self.cached_table_counts = counts
|
self.cached_table_counts = counts
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@ from datasette.utils import (
|
||||||
path_with_added_args,
|
path_with_added_args,
|
||||||
path_with_removed_args,
|
path_with_removed_args,
|
||||||
detect_json1,
|
detect_json1,
|
||||||
InterruptedError,
|
QueryInterrupted,
|
||||||
InvalidSql,
|
InvalidSql,
|
||||||
sqlite3,
|
sqlite3,
|
||||||
)
|
)
|
||||||
|
|
@ -175,7 +175,7 @@ class ColumnFacet(Facet):
|
||||||
),
|
),
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
except InterruptedError:
|
except QueryInterrupted:
|
||||||
continue
|
continue
|
||||||
return suggested_facets
|
return suggested_facets
|
||||||
|
|
||||||
|
|
@ -248,7 +248,7 @@ class ColumnFacet(Facet):
|
||||||
"selected": selected,
|
"selected": selected,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
except InterruptedError:
|
except QueryInterrupted:
|
||||||
facets_timed_out.append(column)
|
facets_timed_out.append(column)
|
||||||
|
|
||||||
return facet_results, facets_timed_out
|
return facet_results, facets_timed_out
|
||||||
|
|
@ -294,7 +294,7 @@ class ArrayFacet(Facet):
|
||||||
),
|
),
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
except (InterruptedError, sqlite3.OperationalError):
|
except (QueryInterrupted, sqlite3.OperationalError):
|
||||||
continue
|
continue
|
||||||
return suggested_facets
|
return suggested_facets
|
||||||
|
|
||||||
|
|
@ -359,7 +359,7 @@ class ArrayFacet(Facet):
|
||||||
"selected": selected,
|
"selected": selected,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
except InterruptedError:
|
except QueryInterrupted:
|
||||||
facets_timed_out.append(column)
|
facets_timed_out.append(column)
|
||||||
|
|
||||||
return facet_results, facets_timed_out
|
return facet_results, facets_timed_out
|
||||||
|
|
@ -406,7 +406,7 @@ class DateFacet(Facet):
|
||||||
),
|
),
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
except (InterruptedError, sqlite3.OperationalError):
|
except (QueryInterrupted, sqlite3.OperationalError):
|
||||||
continue
|
continue
|
||||||
return suggested_facets
|
return suggested_facets
|
||||||
|
|
||||||
|
|
@ -472,7 +472,7 @@ class DateFacet(Facet):
|
||||||
"selected": selected,
|
"selected": selected,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
except InterruptedError:
|
except QueryInterrupted:
|
||||||
facets_timed_out.append(column)
|
facets_timed_out.append(column)
|
||||||
|
|
||||||
return facet_results, facets_timed_out
|
return facet_results, facets_timed_out
|
||||||
|
|
@ -659,7 +659,7 @@ class ManyToManyFacet(Facet):
|
||||||
"selected": selected,
|
"selected": selected,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
except InterruptedError:
|
except QueryInterrupted:
|
||||||
facets_timed_out.append(destination_table)
|
facets_timed_out.append(destination_table)
|
||||||
|
|
||||||
return facet_results, facets_timed_out
|
return facet_results, facets_timed_out
|
||||||
|
|
|
||||||
|
|
@ -46,7 +46,7 @@ ENV SQLITE_EXTENSIONS /usr/lib/x86_64-linux-gnu/mod_spatialite.so
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
||||||
class InterruptedError(Exception):
|
class QueryInterrupted(Exception):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@ from sanic.views import HTTPMethodView
|
||||||
from datasette import __version__
|
from datasette import __version__
|
||||||
from datasette.plugins import pm
|
from datasette.plugins import pm
|
||||||
from datasette.utils import (
|
from datasette.utils import (
|
||||||
InterruptedError,
|
QueryInterrupted,
|
||||||
InvalidSql,
|
InvalidSql,
|
||||||
LimitedWriter,
|
LimitedWriter,
|
||||||
format_bytes,
|
format_bytes,
|
||||||
|
|
@ -368,7 +368,7 @@ class BaseView(RenderMixin):
|
||||||
|
|
||||||
else:
|
else:
|
||||||
data, extra_template_data, templates = response_or_template_contexts
|
data, extra_template_data, templates = response_or_template_contexts
|
||||||
except InterruptedError:
|
except QueryInterrupted:
|
||||||
raise DatasetteError(
|
raise DatasetteError(
|
||||||
"""
|
"""
|
||||||
SQL query took too long. The time limit is controlled by the
|
SQL query took too long. The time limit is controlled by the
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@ from sanic.request import RequestParameters
|
||||||
from datasette.plugins import pm
|
from datasette.plugins import pm
|
||||||
from datasette.utils import (
|
from datasette.utils import (
|
||||||
CustomRow,
|
CustomRow,
|
||||||
InterruptedError,
|
QueryInterrupted,
|
||||||
append_querystring,
|
append_querystring,
|
||||||
compound_keys_after_sql,
|
compound_keys_after_sql,
|
||||||
escape_sqlite,
|
escape_sqlite,
|
||||||
|
|
@ -527,7 +527,7 @@ class TableView(RowTableShared):
|
||||||
await self.ds.execute(database, count_sql, from_sql_params)
|
await self.ds.execute(database, count_sql, from_sql_params)
|
||||||
)
|
)
|
||||||
filtered_table_rows_count = count_rows[0][0]
|
filtered_table_rows_count = count_rows[0][0]
|
||||||
except InterruptedError:
|
except QueryInterrupted:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
# facets support
|
# facets support
|
||||||
|
|
|
||||||
|
|
@ -652,7 +652,7 @@ Each Facet subclass implements a new type of facet operation. The class should l
|
||||||
"results": facet_results_values,
|
"results": facet_results_values,
|
||||||
"truncated": len(facet_rows_results) > facet_size,
|
"truncated": len(facet_rows_results) > facet_size,
|
||||||
}
|
}
|
||||||
except InterruptedError:
|
except QueryInterrupted:
|
||||||
facets_timed_out.append(column)
|
facets_timed_out.append(column)
|
||||||
|
|
||||||
return facet_results, facets_timed_out
|
return facet_results, facets_timed_out
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue