This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: asyncio docs should call out that network logging is a no-no
Type: enhancement Stage: needs patch
Components: asyncio, Documentation Versions: Python 3.4
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: vstinner Nosy List: Mariatta, Winterflower, eric.araujo, socketpair, vstinner, yselivanov
Priority: normal Keywords: patch

Created on 2014-03-03 20:12 by gvanrossum, last changed 2022-04-11 14:57 by admin.

Messages (7)
msg212664 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) Date: 2014-03-03 20:12
The asyncio package uses the logging module. We should remind users that they should always configure their logs to go to a file on the local filesystem -- using any kind of network logging will block the event loop.
msg212666 - (view) Author: Yury Selivanov (yselivanov) * (Python committer) Date: 2014-03-03 20:31
Can we instead re-engineer asyncio logging to have logger calls in a separate thread?

I.e. `logger` is a proxy object, that puts logging calls in a queue, and there would be another thread to block on the queue and do the actual logging. This way it won't really matter how logging is configured.
msg212671 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) Date: 2014-03-03 20:55
If you really need network logging you should be able to configure a handler that puts things in a queue whose other end is serviced by an asyncio task. There should be no need to mess with the type of the logger object. Anyway, in 3.4 it is what it is. :-)
msg212689 - (view) Author: Yury Selivanov (yselivanov) * (Python committer) Date: 2014-03-03 23:44
> If you really need network logging you should be able to configure a handler that puts things in a queue whose other end is serviced by an asyncio task. There should be no need to mess with the type of the logger object.

It's something that is easy to misconfigure. Having [logger+queue+logging thread] combination mitigates the risk a bit, but yeah, at the cost of increased complexity...

> Anyway, in 3.4 it is what it is. :-)

Right.
msg279181 - (view) Author: Mariatta (Mariatta) * (Python committer) Date: 2016-10-22 05:27
Hi, 
I added to asyncio logging doc that the log file should point to a file on local filesystem. 
Please review. Thanks :)
msg279184 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2016-10-22 07:05
+Logs for :mod:`asyncio` module should always point to a file on the local
+filesystem.  Using any kind of network logging will block the event loop.

Well... even writing to a local file can block :-/

By "network", what about the local UNIX socket used by syslog?

I guess that the safest option would be a new asyncio library running
all logs functions to a thread, or maybe using loop.run_in_executor().
msg279371 - (view) Author: Марк Коренберг (socketpair) * Date: 2016-10-25 07:47
Typical network logging is using syslog UDP. Sending UDP is never block.
History
Date User Action Args
2022-04-11 14:57:59adminsetgithub: 65046
2016-11-02 21:28:11Mariattasetfiles: - issue20847.patch
2016-10-25 16:39:46gvanrossumsetnosy: - gvanrossum
2016-10-25 07:47:47socketpairsetnosy: + socketpair
messages: + msg279371
2016-10-22 07:05:47vstinnersetmessages: + msg279184
2016-10-22 05:27:18Mariattasetfiles: + issue20847.patch

nosy: + Mariatta
messages: + msg279181

keywords: + patch
2016-05-18 20:51:45Winterflowersetnosy: + Winterflower
2014-06-06 11:42:55vstinnersetcomponents: + asyncio
2014-05-09 12:53:59ezio.melottisettype: enhancement
components: + Documentation
stage: needs patch
2014-03-07 21:45:34eric.araujosetnosy: + eric.araujo
2014-03-03 23:44:58yselivanovsetmessages: + msg212689
2014-03-03 20:55:43gvanrossumsetmessages: + msg212671
2014-03-03 20:31:41yselivanovsetnosy: + yselivanov
messages: + msg212666
2014-03-03 20:12:20gvanrossumcreate