X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=src%2Fpython-systemd%2Fdocs%2Fjournal.rst;h=9dc495ffdb685ff5b331f822598b82e2a6183366;hb=b04c8c83e8d5670b0923c7cd7d6ea622b0187289;hp=78b831afff05b11aecce5168ca49573a1562d51f;hpb=7f41820b07ccb8a6da5552c466818fcce3d085bf;p=elogind.git diff --git a/src/python-systemd/docs/journal.rst b/src/python-systemd/docs/journal.rst index 78b831aff..9dc495ffd 100644 --- a/src/python-systemd/docs/journal.rst +++ b/src/python-systemd/docs/journal.rst @@ -27,12 +27,23 @@ Accessing the Journal .. autoattribute:: systemd.journal.DEFAULT_CONVERTERS -Whence constants -~~~~~~~~~~~~~~~~ +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() -.. autoattribute:: systemd.journal.SEEK_SET -.. autoattribute:: systemd.journal.SEEK_CUR -.. autoattribute:: systemd.journal.SEEK_END Journal access types ~~~~~~~~~~~~~~~~~~~~