Skip to content

Commit ce6e3c1

Browse files
committed
Merge branch 'master' of github.com:pricingassistant/mrq
2 parents 3de1053 + dc55584 commit ce6e3c1

4 files changed

Lines changed: 26 additions & 19 deletions

File tree

README.md

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -49,16 +49,17 @@ Create a sample project and write a simple task :
4949
$ vim tasks.py
5050
```
5151

52-
53-
from mrq.task import Task
54-
import urllib2
55-
56-
class Fetch(Task):
57-
def run(self, params):
58-
f = urllib2.urlopen(params.get("url"))
59-
t = f.read()
60-
f.close()
61-
return len(t)
52+
```python
53+
from mrq.task import Task
54+
import urllib2
55+
56+
class Fetch(Task):
57+
def run(self, params):
58+
f = urllib2.urlopen(params.get("url"))
59+
t = f.read()
60+
f.close()
61+
return len(t)
62+
```
6263

6364
You can now run it using `mrq-run` :
6465
```
@@ -93,7 +94,7 @@ $ mrq-run --async --queue fetches tasks.Fetch url http://www.google.com &&
9394

9495
Now start the dasbhoard with `mrq-dashboard &` and go check your newly created queue and job on [localhost:5555](http://localhost:5555/#jobs)
9596

96-
Instanciate a worker with `mrq-worker` and you can follow it on the dashboard as it executes in parallel all the enqueued jobs
97+
Instantiate a worker with `mrq-worker` and you can follow it on the dashboard as it executes in parallel all the enqueued jobs
9798

9899
```
99100
$ mrq-worker --gevent 10 fetches
@@ -122,4 +123,4 @@ $ mrq-worker --gevent 10 fetches
122123

123124
# More
124125

125-
Full documentation is available on [readthedocs](http://mrq.readthedocs.org/en/latest/)
126+
Full documentation is available on [readthedocs](http://mrq.readthedocs.org/en/latest/)

docs/jobs.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
# Jobs & Tasks
22

3-
A **Job** is an unit of work that can be added to a Queue. It will be later dequeued by a Worker.
3+
A **Task** is a Python class wrapping a unit of processing. A task may invoke other tasks, synchronously or asynchronously (by queuing them as proper jobs).
44

5-
A **Task** is a Python class wrapping your asynchronous code.
6-
7-
Jobs have a main Task, that will be called when the Job starts. In this Job context, the main Task can then call sub-Tasks or any other Python code.
5+
A **Job** is an instance of the execution of a Task. It must link to a specific Task via it's path and it must have parameters. It must be queued in a Queue. A Worker then dequeues and executes it. The worker updates it with metadata about it's execution : status, traceback ...
86

97
## Job statuses
108

docs/workers.md

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,15 @@
1+
## Worker
12

2-
## Worker statuses
3+
A worker is a unit of processing, that dequeues jobs and executes them.
34

4-
A Worker is always in one of these statuses:
5+
It is started with a list of queues to listen to, in a specific order.
6+
7+
It can be started with concurrency options (multiple processes and / or multiple greenlets). We call this whole group a single 'worker' even though it is able to dequeue multiple jobs in parallel.
8+
9+
10+
## Statuses
11+
12+
At any time, a worker is in one of these statuses:
513

614
* `init`: General worker initialization
715
* `wait`: Waiting for new jobs from Redis

requirements-base.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
argparse==1.1
1+
argparse>=1.1
22
redis==2.10.3
33
pymongo==2.7.2
44
gevent==1.0.1

0 commit comments

Comments
 (0)