Replies: 4 comments 1 reply
This comment was marked as off-topic.
This comment was marked as off-topic.
|
https://trio.readthedocs.io/en/latest/reference-io.html#asynchronous-filesystem-i-o great article about your question |
|
The logging module itself has minimal impact —
import logging
import logging.handlers
from queue import Queue
handler = logging.handlers.RotatingFileHandler("app.log")
queue = Queue(-1)
queue_handler = logging.handlers.QueueHandler(queue)
listener = logging.handlers.QueueListener(queue, handler)
logger = logging.getLogger("myapp")
logger.addHandler(queue_handler)
listener.start()
# Bad — always evaluates str(obj)
logger.debug(f"Processing: {expensive_call()}")
# Good — only formats if DEBUG is enabled
logger.debug("Processing: %s", expensive_call())
For most apps, logging takes <1% of CPU time. The async handler fix addresses the only real issue (blocking I/O in the event loop). |
|
The logging module overhead is negligible for aiohttp.
Set logging.getLogger("aiohttp").setLevel(logging.WARNING) to suppress debug in production. |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
I noticed that the aiohttp uses standard logging for tracking the library activity, But the logging module is threading safe, namely it contains many acquire and release lock operations. will this cause a bad performance to aiohttp in high concurrency environment?
All reactions