mirror of
https://github.com/simonw/datasette.git
synced 2025-12-10 16:51:24 +01:00
Added /-/threads debugging page
This commit is contained in:
parent
0fc8afde0e
commit
a314b76186
2 changed files with 38 additions and 0 deletions
|
|
@ -457,6 +457,15 @@ class Datasette:
|
||||||
for p in ps
|
for p in ps
|
||||||
]
|
]
|
||||||
|
|
||||||
|
def threads(self):
|
||||||
|
threads = list(threading.enumerate())
|
||||||
|
return {
|
||||||
|
"num_threads": len(threads),
|
||||||
|
"threads": [
|
||||||
|
{"name": t.name, "ident": t.ident, "daemon": t.daemon} for t in threads
|
||||||
|
],
|
||||||
|
}
|
||||||
|
|
||||||
def table_metadata(self, database, table):
|
def table_metadata(self, database, table):
|
||||||
"Fetch table-specific metadata."
|
"Fetch table-specific metadata."
|
||||||
return (
|
return (
|
||||||
|
|
@ -621,6 +630,10 @@ class Datasette:
|
||||||
JsonDataView.as_asgi(self, "config.json", lambda: self._config),
|
JsonDataView.as_asgi(self, "config.json", lambda: self._config),
|
||||||
r"/-/config(?P<as_format>(\.json)?)$",
|
r"/-/config(?P<as_format>(\.json)?)$",
|
||||||
)
|
)
|
||||||
|
add_route(
|
||||||
|
JsonDataView.as_asgi(self, "threads.json", self.threads),
|
||||||
|
r"/-/threads(?P<as_format>(\.json)?)$",
|
||||||
|
)
|
||||||
add_route(
|
add_route(
|
||||||
JsonDataView.as_asgi(self, "databases.json", self.connected_databases),
|
JsonDataView.as_asgi(self, "databases.json", self.connected_databases),
|
||||||
r"/-/databases(?P<as_format>(\.json)?)$",
|
r"/-/databases(?P<as_format>(\.json)?)$",
|
||||||
|
|
|
||||||
|
|
@ -90,6 +90,8 @@ Shows the :ref:`config` options for this instance of Datasette. `Config example
|
||||||
"sql_time_limit_ms": 1000
|
"sql_time_limit_ms": 1000
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.. _JsonDataView_databases:
|
||||||
|
|
||||||
/-/databases
|
/-/databases
|
||||||
------------
|
------------
|
||||||
|
|
||||||
|
|
@ -105,3 +107,26 @@ Shows currently attached databases. `Databases example <https://latest.datasette
|
||||||
"size": 225280
|
"size": 225280
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
|
.. _JsonDataView_threads:
|
||||||
|
|
||||||
|
/-/threads
|
||||||
|
----------
|
||||||
|
|
||||||
|
Shows details of threads. `Threads example <https://latest.datasette.io/-/threads>`_::
|
||||||
|
|
||||||
|
{
|
||||||
|
"num_threads": 2,
|
||||||
|
"threads": [
|
||||||
|
{
|
||||||
|
"daemon": false,
|
||||||
|
"ident": 4759197120,
|
||||||
|
"name": "MainThread"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"daemon": true,
|
||||||
|
"ident": 123145319682048,
|
||||||
|
"name": "Thread-1"
|
||||||
|
},
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue