exit error

Create issue
Issue #15 resolved
Lance Linder created an issue

in a simple unit test I receive the error below. it seems like the call to time() is returning None but that doesn't make much sense. when I first started using ddbmock there were no errors but after 5-6 test runs this exit error started showing up. the version of ddbmock is 1.0.1

Error in atexit._run_exitfuncs: Traceback (most recent call last): File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/atexit.py", line 24, in _run_exitfuncs func(targs, *kargs) File "/Library/Python/2.7/site-packages/ddbmock/utils/stat.py", line 84, in flush self._aggregate() File "/Library/Python/2.7/site-packages/ddbmock/utils/stat.py", line 61, in _aggregate self.current_point_time = int(time()) TypeError: 'NoneType' object is not callable

Comments (4)

  1. Éric Araujo

    The error actually means that ddbmock.utils.stat.time is None at the time it is called, which happens when CPython shuts down. The way to avoid that in atexit functions is to hold on a reference to the objects you need instead of using globals, for example: def _aggregate(self, time=time), so that global objects are bound to local objects which live in the function.

    It’s strange that this bug was just discovered. What is your OS and Python version?

  2. Lance Linder reporter

    Éric, Thanks for the explanation. I will take a closer look at this and see if I can't implement your suggestion.

    This is running on OSX 10.8.3 with Python 2.7.2.

  3. Lance Linder reporter

    OK I made some adjustments to the Stat class and the errors are gone. Pull request has been submitted. Thanks for the help!

  4. Log in to comment