taskpool-redis

Task runner for Python apps using redis


Install
pip install taskpool-redis==0.1.1

Documentation

task-pool

Threaded pool for running async tasks in Python apps.

Creating a Task Consumer

from taskpool.pool import TaskWatcher
from myproject.tasks import taskmodule

# Init the pool
pool = TaskWatcher(max_threads=4,
                   redis_url='some-redis-url',
                   task_key='your-key',
                   tasks=taskmodule)
                   
# Start handling tasks
pool.watch()

# Stop handling tasks
pool.unwatch()

Enqueuing Async Tasks

Calling tasks in the pool for instant processing is simple, check it out!

from taskpool.client import TaskClient

# Create the client
task_client = TaskClient(redis_url='some-redis-url', task_key='your-key')

# Call a task
task_client.call('my-sick-task', arg, kwarg='foo')

Scheduling Periodic Tasks

You can also schedule any function for periodic run in the pool. It uses cronjob syntax.

from taskpool.pool import TaskWatcher
from myproject.periodic import periodic_task
from myproject.tasks import taskmodule

# Init the pool
pool = TaskWatcher(max_threads=4,
                   redis_url='some-redis-url',
                   task_key='your-key',
                   tasks=taskmodule)

# Start handling tasks
pool.watch()

# Run a task every month with args and kwargs
pool.schedule(periodic_task, '0 0 1 * *', arg, kwarg=foo)