mirror of
https://github.com/simonw/datasette.git
synced 2026-05-28 12:56:18 +02:00
* Add track_event callback to execute_write_fn and write_wrapper Allows write functions and write_wrapper generators to queue events during a write operation that are dispatched after successful commit. The fn or wrapper can optionally accept a `track_event` parameter (detected via call_with_supported_arguments). Events are discarded if the write raises an exception. Does not yet handle the block=False (non-blocking) case - events queued during non-blocking writes are currently silently discarded. Refs https://github.com/simonw/datasette/issues/2681 * Dispatch track_event events for non-blocking (block=False) writes Spawns a background asyncio task that awaits the write thread's reply queue and dispatches pending events after a successful non-blocking write. Events are still discarded if the write raises an exception. Refs https://github.com/simonw/datasette/issues/2681 * Warn that events won't fire for other processes Refs https://github.com/simonw/datasette/issues/2681#issuecomment-4157118662
16 lines
776 B
Markdown
16 lines
776 B
Markdown
(events)=
|
|
# Events
|
|
|
|
Datasette includes a mechanism for tracking events that occur while the software is running. This is primarily intended to be used by plugins, which can both trigger events and listen for events.
|
|
|
|
The core Datasette application triggers events when certain things happen. This page describes those events.
|
|
|
|
Note that these events will *not* fire for changes made to a SQLite database by a process other than Datasette itself.
|
|
|
|
Plugins can listen for events using the {ref}`plugin_hook_track_event` plugin hook, which will be called with instances of the following classes - or additional classes {ref}`registered by other plugins <plugin_hook_register_events>`.
|
|
|
|
```{eval-rst}
|
|
.. automodule:: datasette.events
|
|
:members:
|
|
:exclude-members: Event
|
|
```
|