summaryrefslogtreecommitdiff
path: root/systemd/docs
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2013-03-07 00:35:28 -0500
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2015-07-05 14:19:17 -0400
commit000525db3e22d76131adbb17bc87b1c7c6426481 (patch)
tree1d55a5e315c8f66fb00b6f9a5bf0ca039486baa8 /systemd/docs
parentcbbe7879266d15b6936b2c766b1c4d9481798145 (diff)
downloadpython-systemd-000525db3e22d76131adbb17bc87b1c7c6426481.tar.gz
systemd-python: export sd_j_get_fd, sd_j_reliable_fd, sd_j_close
sd_journal_get_fd(j) is called j.fileno(), for compatiblity with Python conventions for file-like objects. More importantly, those new .seek_head() and .seek_tail() do not call .get_next(). This is better, if one wants to skip before retrieving an entry.
Diffstat (limited to 'systemd/docs')
-rw-r--r--systemd/docs/journal.rst16
1 files changed, 16 insertions, 0 deletions
diff --git a/systemd/docs/journal.rst b/systemd/docs/journal.rst
index faa2707..9dc495f 100644
--- a/systemd/docs/journal.rst
+++ b/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