def function(self, function, *args, **kwargs) -> asyncio.Task | None:
        """Call a function with current object as argument"""
        try:
            if asyncio.iscoroutinefunction(function):
                return create_task(function(self, *args, **kwargs))
            else:
                return function(self, *args, **kwargs)
        except Exception:
            error = traceback.format_exc()
            logger.error('Exception calling "%s":\n%s', function, error)
            return None
Call a function with current object as argument
libqtile/command/base.py