[issue13569] Loggers cannot be pickled

Nikita Pchelin report at bugs.python.org
Sun Dec 11 01:54:50 CET 2011


Nikita Pchelin <nikita.pchelin at gmail.com> added the comment:

Here is a link for example in question:
https://github.com/jango/calculon/blob/master/calculon/calculon.py

Previously, I would pass logger instance from Calculon class to 
_Producer and _Consumer classes. In the current revision, I removed the 
logging completely since I don't feel like it was serving much purpose 
anyway.

On 11-12-10 06:52 PM, Vinay Sajip wrote:
> Vinay Sajip<vinay_sajip at yahoo.co.uk>  added the comment:
>
> You shouldn't need to pickle loggers, because loggers just represent where in your application something happens (that being determined by the logger name). The logger name is just a string, and if you need to communicate that across e.g. a process boundary, just sending the name should be enough.
>
> Ideally in a multiprocessing application, logging initialisation should happen after the fork() or CreateProcess() which creates the child process. It's best if loggers are named after the module which logs events (using __name__, which means you don't need to pass the name around - but even if you need to for some reason, you still don't need to pickle a logger or pass it around as a parameter).
>
> You *can* use logging safely in terms of the locks it creates to serialise access to I/O resources and to protect shared data structures, but you still need to understand what's happening and allow for it in your own coding.
>
> To summarise, I don't quite see from the information in this issue why it is desirable to pickle loggers, and the GitHub link doesn't work, so I can't look at Nikita's example, either. So if a better justification isn't available, I would like to close the issue.
>
> ----------
>
> _______________________________________
> Python tracker<report at bugs.python.org>
> <http://bugs.python.org/issue13569>
> _______________________________________

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue13569>
_______________________________________


More information about the Python-bugs-list mailing list