Threaded pool for running async tasks in Python apps.
pip install taskpool-redis
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()
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')
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)