run (cron_job)

swarms · swarms/structs/cron_job.py · python · Apache-2.0
automation, tag:background-thread, tag:task-retry

Schedules a recurring task on a background thread and blocks until stopped, handling errors with retries.

# Source: https://github.com/kyegomez/swarms | License: Apache-2.0 | Copyright You must retain, in the Source form of any Derivative Works
# Provided via justclaw.it.com; keep this notice with the code.
    def run(self, task: str, **kwargs):
        """Schedule ``task`` and block, running it every interval until stopped.

        Blocks the calling thread. The task runs on a background thread, so use
        ``KeyboardInterrupt`` (Ctrl-C) or :meth:`stop` from another thread to end
        it. A failing task is logged and retried on the next tick.

        Args:
            task: The task string handed to the agent on every tick.
            **kwargs: Forwarded to the agent's ``run`` on every tick, for example
                ``img="chart.png"`` or ``streaming_callback=fn``.

        Retur

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search for more like it.

Get a free API key