Skip to content
Permalink
Browse files

Added /-/threads debugging page

  • Loading branch information...
simonw committed Oct 2, 2019
1 parent 0fc8afd commit a314b761866d250c16f1ff6dd682010cf4181eb4
Showing with 38 additions and 0 deletions.
  1. +13 −0 datasette/app.py
  2. +25 −0 docs/introspection.rst
@@ -457,6 +457,15 @@ def plugins(self, show_all=False):
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):
"Fetch table-specific metadata."
return (
@@ -621,6 +630,10 @@ def add_route(view, regex):
JsonDataView.as_asgi(self, "config.json", lambda: self._config),
r"/-/config(?P<as_format>(\.json)?)$",
)
add_route(
JsonDataView.as_asgi(self, "threads.json", self.threads),
r"/-/threads(?P<as_format>(\.json)?)$",
)
add_route(
JsonDataView.as_asgi(self, "databases.json", self.connected_databases),
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
}

.. _JsonDataView_databases:

/-/databases
------------

@@ -105,3 +107,26 @@ Shows currently attached databases. `Databases example <https://latest.datasette
"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"
},
]
}

0 comments on commit a314b76

Please sign in to comment.
You can’t perform that action at this time.