summaryrefslogtreecommitdiff
path: root/src/python-systemd/docs/journal.rst
diff options
context:
space:
mode:
Diffstat (limited to 'src/python-systemd/docs/journal.rst')
-rw-r--r--src/python-systemd/docs/journal.rst16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/python-systemd/docs/journal.rst b/src/python-systemd/docs/journal.rst
index faa270746d..9dc495ffdb 100644
--- a/src/python-systemd/docs/journal.rst
+++ b/src/python-systemd/docs/journal.rst
@@ -27,6 +27,22 @@ Accessing the Journal
.. autoattribute:: systemd.journal.DEFAULT_CONVERTERS
+Example: polling for journal events
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+This example shows that journal events can be waited for (using
+e.g. `poll`). This makes it easy to integrate Reader in an external
+event loop:
+
+ >>> import select
+ >>> from systemd import journal
+ >>> j = journal.Reader()
+ >>> j.seek_tail()
+ >>> p = select.poll()
+ >>> p.register(j, select.POLLIN)
+ >>> p.poll()
+ [(3, 1)]
+ >>> j.get_next()
Journal access types