<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">2015-05-02 16:18 GMT+02:00 Zbigniew Jędrzejewski-Szmek <span dir="ltr"><<a href="mailto:zbyszek@in.waw.pl" target="_blank">zbyszek@in.waw.pl</a>></span>:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><span class="">On Sat, May 02, 2015 at 03:34:52PM +0200, Ludovic Gasc wrote:<br>
> Ok, my bad, I didn't see JournalHandler class to use with Python logging:<br>
> <a href="http://www.freedesktop.org/software/systemd/python-systemd/journal.html#journalhandler-class" target="_blank">http://www.freedesktop.org/software/systemd/python-systemd/journal.html#journalhandler-class</a><br>
><br>
> Nevertheless, my question about communication between Python and journald<br>
> remains.<br>
</span>Can you rephrase the question? I don't quite understand what functionality<br>
you're missing from<br>
<a href="http://www.freedesktop.org/software/systemd/python-systemd/journal.html#systemd.journal.send" target="_blank">http://www.freedesktop.org/software/systemd/python-systemd/journal.html#systemd.journal.send</a> .<br>
<br></blockquote><div><br></div><div>In AsyncIO, when you interact with the outside world, you need to use "yield from", for example:</div><div><a href="https://docs.python.org/3/library/asyncio-stream.html#tcp-echo-client-using-streams">https://docs.python.org/3/library/asyncio-stream.html#tcp-echo-client-using-streams</a><br></div><div><br></div><div>"yield from" means to the Python interpreter to "pause" the coroutine to work on another coroutine until data arrive.</div><div>To be efficient, I/O should handled by AsyncIO, even if some workarounds are possible if the raw socket isn't accessible.</div><div><br></div><div>If this pattern is useful for HTTP requests, for logging where you shouldn't wait a return, it isn't very critical, especially if you use syslog protocol with UNIX socket.</div><div><br></div><div>Nevertheless, to be sure, I wish to understand how the communication works between my process and journald daemon.</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
Zbyszek<br>
<span class=""><br>
><br>
> --<br>
> Ludovic Gasc (GMLudo)<br>
> <a href="http://www.gmludo.eu/" target="_blank">http://www.gmludo.eu/</a><br>
><br>
> 2015-05-02 15:12 GMT+02:00 Ludovic Gasc <<a href="mailto:gmludo@gmail.com">gmludo@gmail.com</a>>:<br>
><br>
> > Hi,<br>
> ><br>
> > With the new release of Debian Jessie and systemd+journald integration,<br>
> > I'm looking for how to modernize our Python 3 toolbox to build daemons.<br>
> ><br>
> > For now on Debian Wheezy, we use a SysLogHandler with UNIX socket:<br>
> > <a href="https://docs.python.org/3.4/library/logging.handlers.html#sysloghandler" target="_blank">https://docs.python.org/3.4/library/logging.handlers.html#sysloghandler</a><br>
> > + a custom rsyslog+logrotate configuration to split and manage log files.<br>
> ><br>
> > From sysvinit to systemd migration to start our daemons, it should be<br>
> > easy, I've found this documentation:<br>
> > <a href="http://gunicorn-docs.readthedocs.org/en/latest/deploy.html#systemd" target="_blank">http://gunicorn-docs.readthedocs.org/en/latest/deploy.html#systemd</a><br>
> ><br>
> > But for journald, even if I can use syslog UNIX socket provided by<br>
> > journald, I want to benefit the features of journald, especially structured<br>
> > logs.<br>
> ><br>
> > I've seen the Python binding for journald:<br>
> > <a href="http://www.freedesktop.org/software/systemd/python-systemd/journal.html" target="_blank">http://www.freedesktop.org/software/systemd/python-systemd/journal.html</a><br>
> > Nevertheless, I've two questions:<br>
> ><br>
</span>> >    1. I've seen no python logging handler for journald. Is it a desired<br>
<span class="">> >    situation or it's because no time to implement that ? Could you be<br>
> >    interested in by an handler with journald ?<br>
</span>> >    2. We use heavily AsyncIO module to have async pattern in Python,<br>
<span class="">> >    especially for I/O: <a href="https://docs.python.org/3/library/asyncio.html" target="_blank">https://docs.python.org/3/library/asyncio.html</a><br>
> >    In the source code of python-systemd, I've seen that you use a C glue<br>
> >    to interact with journald, but I don't understand what's the communication<br>
> >    between my Python daemon process and journald: unix sockets ? Other<br>
> >    mechanism ? Depends on the mechanism, it should be have an impact for us.<br>
> ><br>
> > Thanks for your answers.<br>
> ><br>
> > Have a nice week-end.<br>
> > --<br>
> > Ludovic Gasc (GMLudo)<br>
> > <a href="http://www.gmludo.eu/" target="_blank">http://www.gmludo.eu/</a><br>
> ><br>
<br>
</span>> _______________________________________________<br>
> systemd-devel mailing list<br>
> <a href="mailto:systemd-devel@lists.freedesktop.org">systemd-devel@lists.freedesktop.org</a><br>
> <a href="http://lists.freedesktop.org/mailman/listinfo/systemd-devel" target="_blank">http://lists.freedesktop.org/mailman/listinfo/systemd-devel</a><br>
<br>
</blockquote></div><br></div></div>