language: python
python:
+ - "3.4"
- "3.3"
- "2.7"
- "2.6"
__author__ = 'Daniel Greenfeld'
__email__ = 'pydanny@gmail.com'
-__version__ = '0.1.4'
+__version__ = '0.1.5'
__license__ = 'BSD'
-import time
import threading
return obj.__dict__[prop_name]
# If not, do the calculation and release the lock.
- return super(threaded_cached_property, self).__get__(obj, cls)
\ No newline at end of file
+ return super(threaded_cached_property, self).__get__(obj, cls)
except ImportError:
from distutils.core import setup
-__version__ = '0.1.4'
+__version__ = '0.1.5'
readme = open('README.rst').read()
history = open('HISTORY.rst').read().replace('.. :changelog:', '')
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.3',
+ 'Programming Language :: Python :: 3.4',
],
)
class TestThreadingIssues(unittest.TestCase):
def test_threads(self):
- """ How well does this implementation work with threads?"""
+ """ How well does the standard cached_property implementation work with threads?
+ Short answer: It doesn't! Use threaded_cached_property instead!
+ """
class Check(object):
for thread in threads:
thread.join()
- # TODO: This assertion should be working.
- # See https://github.com/pydanny/cached-property/issues/6
- # self.assertEqual(c.add_cached, 1)
+ # Threads means that caching is bypassed.
+ self.assertNotEqual(c.add_cached, 1)
- # TODO: This assertion should be failing.
- # See https://github.com/pydanny/cached-property/issues/6
# This assertion hinges on the fact the system executing the test can
# spawn and start running num_threads threads within the sleep period
# (defined in the Check class as 1 second). If num_threads were to be