skip to navigation
skip to content

Not Logged In

carotte 0.0.7

Carotte is a very lightweight Celery on zmq

Latest Version: 0.2.0

Carotte is a very lightweight Celery on zmq.

Install

pip install carotte

Getting started

Create your tasks.py:

from carotte import task

@task
def hello_world(name):
    return 'Hello %s!' % name

Run your worker (default on “tcp://127.0.0.1:5550”):

carotte worker --tasks-module tasks

Run your client:

>>> from carotte import Client
>>> client = Client()
>>> task = client.run_task('hello_world', ['foo'])
>>> task.success
>>> True
>>> task.result
>>> 'Hello foo!'

Scheduled tasks

Carotte is not a scheduler, its a asynchronous tasks runner. But you can really set up scheduled tasks with schedule.

Your tasks.py:

import requests
from carote import task

@task
def get(url):
    r = requests.get(url)
    if r.status_code != 200:
        # Do stuff
        return False
    return True

Your scheduler.py:

import time
import schedule
from carotte import client

client = Client()
schedule.every(10).seconds.do(client.run_task, 'get', ['http://google.com'])

while True:
    schedule.run_pending()
    time.sleep(1)

Run your worker and your scheduler:

carotte worker --tasks-module tasks
# In another terminal
python scheduler.py
 
File Type Py Version Uploaded on Size
carotte-0.0.7.tar.gz (md5) Source 2014-04-04 7KB
  • Downloads (All Versions):
  • 15 downloads in the last day
  • 162 downloads in the last week
  • 459 downloads in the last month