This repository is private.
All pages are served over SSL and all pushing and pulling is done over SSH.
No one may fork, clone, or view it unless they are added as a member.
Every repository with this icon (
) is private.
Every repository with this icon (
This repository is public.
Anyone may fork, clone, or view it.
Every repository with this icon (
) is public.
Every repository with this icon (
Harish Mallipeddi (author)
Sat Jul 25 01:29:11 -0700 2009
| name | age | message | |
|---|---|---|---|
| |
.gitignore | Sat Jul 25 01:09:58 -0700 2009 | |
| |
LICENSE | Fri May 16 12:38:42 -0700 2008 | |
| |
README | Sat Jul 25 01:29:11 -0700 2009 | |
| |
TODO | Sat Jul 25 01:29:11 -0700 2009 | |
| |
__init__.py | Fri May 16 12:17:06 -0700 2008 | |
| |
base.py | Fri May 16 07:59:18 -0700 2008 | |
| |
client.py | Fri May 16 12:17:06 -0700 2008 | |
| |
daemon.py | Wed May 28 22:40:28 -0700 2008 | |
| |
exceptions.py | Wed May 14 09:36:43 -0700 2008 | |
| |
http/ | Sat Jul 25 01:09:58 -0700 2009 | |
| |
management/ | Wed May 28 22:40:28 -0700 2008 | |
| |
service.py | Fri May 16 12:17:06 -0700 2008 | |
| |
utils.py | Fri May 16 12:17:06 -0700 2008 |
README
django-taskforce
django-taskforce implements a job server for Django apps. It lets you execute long-running tasks asynchronously in a
separate process. Since a Django application blocks while serving a request it is best to move long-running tasks off
into a background process that is divorced from http request/response cycle.
Note of caution: django-taskforce is a bit incomplete - I wrote this quickly for a side-project over a couple of days.
If you're going to use this in high-profile apps in production, then be aware there's a long TODO list :) But seriously
you should really be using something like gearman :)
How it works:
taskforce includes :
daemon - a separate worker process (has a thread-pool of n worker threads waiting for tasks). Worker process is a
simple web.py HTTP daemon which exposes a simple REST API for clients to submit tasks.
client library - used to submit tasks, check status, and fetch results from within your Django app.
DEPENDENCIES
* Install web.py ($easy_install web.py)
AUTHOR:
Harish Mallipeddi - http://blog.poundbang.in/
INSTRUCTIONS:
0) If you don't have web.py installed, do $easy_install web.py
1) Add 'taskforce' to INSTALLED_APPS in settings.py of your project
2) Create tasks.py under your app folder. taskforce will automatically pick up all the Tasks that you define here just
like how Django picks up all the models that you define in models.py.
3) Here's a sample task which waits for 'a' secs and return 'a' (add this to tasks.py that you created above)
import taskforce, time
# Create your models here.
class MyTask(taskforce.BaseTask):
def run(self, a):
for i in range(a, 0, -1):
self.progress = "%d secs to go..." % i
time.sleep(1)
self.progress = "done!"
return a
4) In your views.py, you can invoke/check status/fetch results of the task as follows:
Taskforce.submit_new('task1', tasks.MyTask, 10)
while not Taskforce.has_finished('task1'):
time.sleep(1)
continue
print Taskforce.fetch_results('task1')
5) There are some management commands to launch the taskforce worker threads.
./manage.py help start_taskforce
./manage.py help stop_taskforce







