Example #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)
Example #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))
Example #5
0
 def test_static_method(self):
     self.assertFalse(reflection.is_bound_method(Class.static_method))
Example #6
0
 def test_baddy(self):
     b = BadClass()
     self.assertTrue(reflection.is_bound_method(b.do_something))