Python Setup

Get started with Schedo in your Python application in minutes.

Installation

Install the Schedo Python client using pip:

python
1pip install schedo

Basic Usage

Import and initialize the Schedo client with your API key:

python
1class=class="text-amber-300">"text-gray-500"># Import and initialize
2from schedo import Schedo
3
4class=class="text-amber-300">"text-gray-500"># Initialize with your API key
5schedo = Schedo(api_key=class="text-amber-300">"YOUR_API_KEY")

Scheduling Jobs

Schedule your first job with a cron expression:

python
1class=class="text-amber-300">"text-gray-500"># Define and register a job with cron schedule
2class="text-red-400">@schedo.cron(class="text-amber-300">"*/3 * * * *")  class=class="text-amber-300">"text-gray-500"># Run every 3 minutes
3def process_data():
4    class=class="text-amber-300">"text-gray-500"># Your job logic here
5    print(class="text-amber-300">"Processing data batch...")
6    return True
7
8class=class="text-amber-300">"text-gray-500"># Start the scheduler
9if __name__ == class="text-amber-300">"__main__":
10    schedo.start()

Error Handling

Handle job failures and retries:

python
1class="text-red-400">@schedo.cron(class="text-amber-300">"0 */2 * * *", max_retries=3)
2def process_orders(ctx):
3    try:
4        process_pending_orders()
5    except Exception as error:
6        ctx.logger.error(fclass="text-amber-300">"Failed to process orders: {error}")
7        raise  class=class="text-amber-300">"text-gray-500"># Schedo will handle retries

Documentation

For more detailed information and advanced features, please refer to our documentation: