osdir.com

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

How to use Python's built-in Logging with Asyncio (Permission Error)


I'm spit-balling here, but I suspect the problem is that
TimedRotatingFileHandler was probably not designed to have multiple
instances of it in different processes all trying to rotate the same
file. Yet that's the situation you have since each subprocess in your
process pool creates its own handler instance.

I've not used it myself, but I believe that this is effectively the
problem that QueueHandler and QueueListener were created to solve:
https://docs.python.org/3.7/library/logging.handlers.html#queuehandler

The parent process should create a queue and a QueueListener to
service that queue, using the TimedRotatingFileHandler. Each
subprocess should log to the queue using QueueHandler instead. This
way the actual log file is only handled by one process.
On Mon, Oct 8, 2018 at 1:54 PM <liamhanninen at gmail.com> wrote:
>
> From the logging docs I found out there was another avenue (comp.lang.python) to ask questions about it. I already posted to stackoverflow but if anyone could help out here or via stackoverflow I would greatly appreciate it. Here is the link to my question:
>
> https://stackoverflow.com/questions/52708756/how-to-use-pythons-built-in-logging-with-asyncio-permission-error
> --
> https://mail.python.org/mailman/listinfo/python-list