Esempio n. 1
0
    def test_simple_delete(self):
        d = local()
        d.a = 1
        assert d.a == 1
        del d.a

        def f():
            return d.a

        with pytest.raises(AttributeError):
            f()
Esempio n. 2
0
    def test_local(self):
        d = local()
        d.a = 1

        r_list = []

        def f():
            try:
                d.a
            except AttributeError:
                r_list.append(True)

        core.tasklet(f)()
        core.schedule()

        assert r_list == [True]
Esempio n. 3
0
# -*- coding: utf-8 -
#
# This file is part of flower. See the NOTICE for more information.

import operator
import threading

import six

from flower import core
from flower.local import local

_local = local()

class Registry(object):
    """ actors registry. This rgistry is used to keep a trace of created
    actors """

    __slots__ = ['__dict__', '_lock']

    # share state between instances
    __shared_state__ = dict(
            _registered_names = {},
            _by_ref = {}
    )

    def __init__(self):
        self.__dict__ = self.__shared_state__
        self._lock = threading.RLock()

Esempio n. 4
0
 def test_simple(self):
     d = local()
     d.a = 1
     assert d.a == 1
     d.a = 2
     assert d.a == 2