kopia lustrzana https://github.com/simonw/datasette
Added num_sql_threads config option, closes #285
rodzic
276913b748
commit
7944a8b0de
|
@ -59,6 +59,9 @@ CONFIG_OPTIONS = (
|
|||
ConfigOption("max_returned_rows", 1000, """
|
||||
Maximum rows that can be returned from a table or custom query
|
||||
""".strip()),
|
||||
ConfigOption("num_sql_threads", 3, """
|
||||
Number of threads in the thread pool for executing SQLite queries
|
||||
""".strip()),
|
||||
ConfigOption("sql_time_limit_ms", 1000, """
|
||||
Time limit for a SQL query in milliseconds
|
||||
""".strip()),
|
||||
|
@ -124,7 +127,6 @@ class Datasette:
|
|||
def __init__(
|
||||
self,
|
||||
files,
|
||||
num_threads=3,
|
||||
cache_headers=True,
|
||||
cors=False,
|
||||
inspect_data=None,
|
||||
|
@ -136,8 +138,6 @@ class Datasette:
|
|||
config=None,
|
||||
):
|
||||
self.files = files
|
||||
self.num_threads = num_threads
|
||||
self.executor = futures.ThreadPoolExecutor(max_workers=num_threads)
|
||||
self.cache_headers = cache_headers
|
||||
self.cors = cors
|
||||
self._inspect = inspect_data
|
||||
|
@ -148,6 +148,9 @@ class Datasette:
|
|||
self.plugins_dir = plugins_dir
|
||||
self.static_mounts = static_mounts 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.sql_time_limit_ms = self.config["sql_time_limit_ms"]
|
||||
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
|
||||
|
||||
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
|
||||
-----------
|
||||
|
||||
|
|
|
@ -940,6 +940,7 @@ def test_config_json(app_client):
|
|||
"suggest_facets": True,
|
||||
"allow_sql": True,
|
||||
"default_cache_ttl": 365 * 24 * 60 * 60,
|
||||
"num_sql_threads": 3,
|
||||
} == response.json
|
||||
|
||||
|
||||
|
|
Ładowanie…
Reference in New Issue