* updated README

* both func and hook check for callable.
This commit is contained in:
Ilan Steemers
2015-06-26 14:24:25 +02:00
parent 28d6c26256
commit 666bdc97dc
7 changed files with 158 additions and 46 deletions
+34 -1
View File
@@ -16,8 +16,41 @@ Schedule the asynchronous execution of a function by calling `async` from within
```python
async(func,*args,hook=None,**kwargs)
```
The optional hook function gets the finished task object as its first argument after execution
####Basic example
```python
from django_q import async
# math.copysign(2,-2)
async('math.copysign', 2, -2)
# also
from math import copysign
async(copysign, 2, -2)
```
#### Result example
```python
from django_q import async, result
# create the task
task_id = async('math.copysign', 2, -2)
# get the result
task_result = result(task_id)
# result returns None if the task has not been executed yet
# so it makes more sense to use a hook:
from hooks import print_result
async('math.modf', 2.5, hook='hooks.print_result')
# hooks.py
def print_result(task):
print(task.result)
```
### Management commands
#### `qcluster`