Exemple #1
0
    def create(cls, objects, exclude_hidden=True):
        """Automatically creates a worker by analyzing object(s) methods.

        Only picks up methods that have been tagged/decorated with
        the :py:func:`.periodic` decorator (does not match against private
        or protected methods unless explicitly requested to).
        """
        callables = []
        for obj in objects:
            for (name, member) in inspect.getmembers(obj):
                if name.startswith("_") and exclude_hidden:
                    continue
                if reflection.is_bound_method(member):
                    missing_attrs = _check_attrs(member)
                    if not missing_attrs:
                        callables.append(member)
        return cls(callables)
Exemple #2
0
    def create(cls, objects, exclude_hidden=True):
        """Automatically creates a worker by analyzing object(s) methods.

        Only picks up methods that have been tagged/decorated with
        the :py:func:`.periodic` decorator (does not match against private
        or protected methods unless explicitly requested to).
        """
        callables = []
        for obj in objects:
            for (name, member) in inspect.getmembers(obj):
                if name.startswith("_") and exclude_hidden:
                    continue
                if reflection.is_bound_method(member):
                    missing_attrs = _check_attrs(member)
                    if not missing_attrs:
                        callables.append(member)
        return cls(callables)
 def test_static_method(self):
     self.assertFalse(reflection.is_bound_method(Class.static_method))
 def test_baddy(self):
     b = BadClass()
     self.assertTrue(reflection.is_bound_method(b.do_something))
 def test_static_method(self):
     self.assertFalse(reflection.is_bound_method(Class.static_method))
 def test_baddy(self):
     b = BadClass()
     self.assertTrue(reflection.is_bound_method(b.do_something))