[systemd-devel] Journald logging handler for Python 3 and AsyncIO integration

Lennart Poettering lennart at poettering.net
Sun May 3 18:16:41 PDT 2015


On Sat, 02.05.15 15:12, Ludovic Gasc (gmludo at gmail.com) wrote:

>    2. We use heavily AsyncIO module to have async pattern in Python,
>    especially for I/O: https://docs.python.org/3/library/asyncio.html
>    In the source code of python-systemd, I've seen that you use a C glue to
>    interact with journald, but I don't understand what's the communication
>    between my Python daemon process and journald: unix sockets ? Other
>    mechanism ? Depends on the mechanism, it should be have an impact for us.

The communication is via an AF_UNIX/SOCK_DGRAM socket in the file
system.

I am very sure that logging should not be asynchronous non-blocking
IO. It's about reliably getting out log messages at the right times,
and that's a property you lose if you enqueue logs non-blocking.

I don't think that's a good idea in any programming language to log
asynchronously. I mean, there's a reason why libc syslog() is
blocking too.

If you are afraid of blocking logging, then make sure to use large
socket buffers. the journal client library and journald will try to
use very large buffers, but this doesn't always work if the client is
unprivileged. Also you might have to increase the number of datagrams
that may be queued with /proc/sys/net/unix/max_dgram_qlen


Lennart

-- 
Lennart Poettering, Red Hat


More information about the systemd-devel mailing list