How to use the rele.worker.create_and_run function in rele

To help you get started, we’ve selected a few rele examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github mercadona / rele / tests / test_worker.py View on Github external
def test_waits_forever_when_called_with_config_and_subs(self, config, mock_worker):
        subscriptions = (sub_stub,)
        create_and_run(subscriptions, config)

        mock_worker.assert_called_with(subscriptions, "rele-test", ANY, 60, 2)
        mock_worker.return_value.run_forever.assert_called_once_with()
github mercadona / rele / rele / __main__.py View on Github external
"--settings",
        "-s",
        default=None,
        required=False,
        help="Settings file dot path. Ex. project.settings. "
        "If none is supplied, Relé will attempt to autodiscover in the root path.",
    )
    args = parser.parse_args()

    if args.command == "run":
        settings, module_paths = discover.sub_modules(args.settings)
        configuration = config.setup(settings.RELE if settings else None)
        subs = config.load_subscriptions_from_paths(
            module_paths, configuration.sub_prefix, configuration.filter_by
        )
        create_and_run(subs, configuration)
github mercadona / rele / rele / management / commands / runrele.py View on Github external
def handle(self, *args, **options):
        if all(map(lambda x: x.get("CONN_MAX_AGE"), settings.DATABASES.values())):
            self.stderr.write(
                self.style.WARNING(
                    "WARNING: settings.CONN_MAX_AGE is not set to 0. "
                    "This may result in slots for database connections to "
                    "be exhausted."
                )
            )
        subs = config.load_subscriptions_from_paths(
            discover_subs_modules(), self.config.sub_prefix, self.config.filter_by
        )
        self.stdout.write(f"Configuring worker with {len(subs)} " f"subscription(s)...")
        create_and_run(subs, self.config)