Ejemplo n.º 1
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)
Ejemplo n.º 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
Ejemplo n.º 3
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
Ejemplo n.º 4
0
def jsonrpc_reset(body):
    reset_threadlocal()
    threadlocal.set('client', body.get('websocket_client'))
Ejemplo n.º 5
0
 def with_caching(self):
     val = threadlocal.get(name)
     if val is None:
         val = func(self)
         threadlocal.set(name, val)
     return val
Ejemplo n.º 6
0
 def with_caching(self):
     val = threadlocal.get(name)
     if val is None:
         val = func(self)
         threadlocal.set(name, val)
     return val