コード例 #1
0
def test_request_cached_property():
    class Foo(object):
        @request_cached_property
        def bar(self):
            return 5

    name = __name__ + '.bar'
    foo = Foo()
    assert threadlocal.get(name) is None
    assert 5 == foo.bar
    assert 5 == threadlocal.get(name)
    threadlocal.set(name, 6)
    assert 6 == foo.bar
    assert 6 == Foo().bar  # cache is shared between instances
コード例 #2
0
def test_request_cached_property():
    class Foo(object):
        @request_cached_property
        def bar(self):
            return 5

    name = __name__ + '.bar'
    foo = Foo()
    assert threadlocal.get(name) is None
    assert 5 == foo.bar
    assert 5 == threadlocal.get(name)
    threadlocal.set(name, 6)
    assert 6 == foo.bar
    assert 6 == Foo().bar  # cache is shared between instances
コード例 #3
0
    def _init(self, session, raise_errors):
        self.session = session
        self.raise_errors = raise_errors
        self.results = {
            'running': True,
            'completed': False,
            'categories': defaultdict(lambda: defaultdict(int))
        }

        # note: this will get cleared after request_cached_context object is released.
        assert not threadlocal.get('currently_running_email_daemon')
        threadlocal.set('currently_running_email_daemon', self)
コード例 #4
0
ファイル: _services.py プロジェクト: msg4real/sideboard
 def poll(self):
     """empty method which exists only to help keep WebSockets alive"""
     log.debug('sideboard.poll by user {}', threadlocal.get('username'))
コード例 #5
0
ファイル: test_lib.py プロジェクト: ftobia/sideboard
 def index(self):
     return threadlocal.get('username')
コード例 #6
0
 def _currently_running_daemon_on_this_thread(cls):
     return threadlocal.get('currently_running_email_daemon')
コード例 #7
0
 def with_caching(self):
     val = threadlocal.get(name)
     if val is None:
         val = func(self)
         threadlocal.set(name, val)
     return val
コード例 #8
0
ファイル: _utils.py プロジェクト: magfest/sideboard
 def with_caching(self):
     val = threadlocal.get(name)
     if val is None:
         val = func(self)
         threadlocal.set(name, val)
     return val