mirror of
https://github.com/simonw/datasette.git
synced 2025-12-10 16:51:24 +01:00
Added num_sql_threads config option, closes #285
This commit is contained in:
parent
276913b748
commit
7944a8b0de
3 changed files with 16 additions and 3 deletions
|
|
@ -59,6 +59,9 @@ CONFIG_OPTIONS = (
|
||||||
ConfigOption("max_returned_rows", 1000, """
|
ConfigOption("max_returned_rows", 1000, """
|
||||||
Maximum rows that can be returned from a table or custom query
|
Maximum rows that can be returned from a table or custom query
|
||||||
""".strip()),
|
""".strip()),
|
||||||
|
ConfigOption("num_sql_threads", 3, """
|
||||||
|
Number of threads in the thread pool for executing SQLite queries
|
||||||
|
""".strip()),
|
||||||
ConfigOption("sql_time_limit_ms", 1000, """
|
ConfigOption("sql_time_limit_ms", 1000, """
|
||||||
Time limit for a SQL query in milliseconds
|
Time limit for a SQL query in milliseconds
|
||||||
""".strip()),
|
""".strip()),
|
||||||
|
|
@ -124,7 +127,6 @@ class Datasette:
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
files,
|
files,
|
||||||
num_threads=3,
|
|
||||||
cache_headers=True,
|
cache_headers=True,
|
||||||
cors=False,
|
cors=False,
|
||||||
inspect_data=None,
|
inspect_data=None,
|
||||||
|
|
@ -136,8 +138,6 @@ class Datasette:
|
||||||
config=None,
|
config=None,
|
||||||
):
|
):
|
||||||
self.files = files
|
self.files = files
|
||||||
self.num_threads = num_threads
|
|
||||||
self.executor = futures.ThreadPoolExecutor(max_workers=num_threads)
|
|
||||||
self.cache_headers = cache_headers
|
self.cache_headers = cache_headers
|
||||||
self.cors = cors
|
self.cors = cors
|
||||||
self._inspect = inspect_data
|
self._inspect = inspect_data
|
||||||
|
|
@ -148,6 +148,9 @@ class Datasette:
|
||||||
self.plugins_dir = plugins_dir
|
self.plugins_dir = plugins_dir
|
||||||
self.static_mounts = static_mounts or []
|
self.static_mounts = static_mounts or []
|
||||||
self.config = dict(DEFAULT_CONFIG, **(config or {}))
|
self.config = dict(DEFAULT_CONFIG, **(config or {}))
|
||||||
|
self.executor = futures.ThreadPoolExecutor(
|
||||||
|
max_workers=self.config["num_sql_threads"]
|
||||||
|
)
|
||||||
self.max_returned_rows = self.config["max_returned_rows"]
|
self.max_returned_rows = self.config["max_returned_rows"]
|
||||||
self.sql_time_limit_ms = self.config["sql_time_limit_ms"]
|
self.sql_time_limit_ms = self.config["sql_time_limit_ms"]
|
||||||
self.page_size = self.config["default_page_size"]
|
self.page_size = self.config["default_page_size"]
|
||||||
|
|
|
||||||
|
|
@ -38,6 +38,15 @@ You can increase or decrease this limit like so::
|
||||||
|
|
||||||
datasette mydatabase.db --config max_returned_rows:2000
|
datasette mydatabase.db --config max_returned_rows:2000
|
||||||
|
|
||||||
|
num_sql_threads
|
||||||
|
---------------
|
||||||
|
|
||||||
|
Maximum number of threads in the thread pool Datasette uses to execute SQLite queries. Defaults to 3.
|
||||||
|
|
||||||
|
::
|
||||||
|
|
||||||
|
datasette mydatabase.db --config num_sql_threads:10
|
||||||
|
|
||||||
allow_facet
|
allow_facet
|
||||||
-----------
|
-----------
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -940,6 +940,7 @@ def test_config_json(app_client):
|
||||||
"suggest_facets": True,
|
"suggest_facets": True,
|
||||||
"allow_sql": True,
|
"allow_sql": True,
|
||||||
"default_cache_ttl": 365 * 24 * 60 * 60,
|
"default_cache_ttl": 365 * 24 * 60 * 60,
|
||||||
|
"num_sql_threads": 3,
|
||||||
} == response.json
|
} == response.json
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue