Code Monkey home page Code Monkey logo

pbk's People

Contributors

wvaske avatar dnwobu avatar

Stargazers

 avatar

Watchers

James Cloos avatar Kostas Georgiou avatar John Mazzie avatar

Forkers

dnwobu

pbk's Issues

PerLogger as is can't be pickled in Python 3.7+

I'm not sure if you've run into this but I'm using your logger for the work I'm doing (so great!). If you try to do the simple case of pickle on the PerfLogger:

from pbk.util.perflogger import configure_basic_logger
logger = configure_basic_logger('test')
import pickle
pickle.dumps(logger)
Traceback (most recent call last):
  File "<input>", line 1, in <module>
  File "/opt/.../python3.8/logging/__init__.py", line 1727, in __reduce__
    raise pickle.PicklingError('logger cannot be pickled')
_pickle.PicklingError: logger cannot be pickled

Below is the code segment in question:

    def __reduce__(self):
        # In general, only the root logger will not be accessible via its name.
        # However, the root logger's class has its own __reduce__ method.
        if getLogger(self.name) is not self:
            import pickle
            raise pickle.PicklingError('logger cannot be pickled')
        return getLogger, (self.name,)

Pretty much, when getLogger is called on Perflogger the value returned is not the same as what is given for the root logger. In other words, the value the root logger gets with getLogger is not the same as PerfLogger __repr__:

logger
<PerfLogger test (DEBUG)>
logging.getLogger(logger.name)
<PerfLogger test (WARNING)>

Hopefully, the fix should be easy. I'll fix it in my environment before i need to actually need to pickle. I wanted to give you a heads up in case you wanted to fix it before I submit a PR sometime this week.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.