mirror of
https://github.com/morgan9e/systemd
synced 2026-04-15 17:06:39 +09:00
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.
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user