Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 2a8fab7

Browse files
authored
Clean up code block formatting in README
1 parent 4fe3e7e commit 2a8fab7

File tree

1 file changed

+23
-11
lines changed

1 file changed

+23
-11
lines changed

README.md

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@ Supported and tested against:
1616

1717
Install from PIP
1818

19-
pip install django-db-queue
19+
```
20+
pip install django-db-queue
21+
```
2022

2123
Add `django_dbq` to your installed apps
2224

@@ -29,7 +31,9 @@ INSTALLED_APPS = [
2931

3032
Run migrations
3133

32-
manage.py migrate
34+
```
35+
manage.py migrate
36+
```
3337

3438
### Upgrading from 1.x to 2.x
3539

@@ -112,7 +116,9 @@ JOBS = {
112116

113117
In another terminal:
114118

115-
`python manage.py worker`
119+
```
120+
python manage.py worker
121+
```
116122

117123
### Create a job
118124

@@ -186,11 +192,13 @@ def my_task(job):
186192

187193
Tasks within a single job can use the workspace to communicate with each other. A single task can edit the workspace, and the modified workspace will be passed on to the next task in the sequence. For example:
188194

189-
def my_first_task(job):
190-
job.workspace['message'] = 'Hello, task 2!'
195+
```python
196+
def my_first_task(job):
197+
job.workspace['message'] = 'Hello, task 2!'
191198

192-
def my_second_task(job):
193-
logger.info("Task 1 says: %s" % job.workspace['message'])
199+
def my_second_task(job):
200+
logger.info("Task 1 says: %s" % job.workspace['message'])
201+
```
194202

195203
The workspace can be queried like any [JSONField](https://docs.djangoproject.com/en/3.2/topics/db/queries/#querying-jsonfield). For instance, if you wanted to display a list of jobs that a certain user had initiated, add `user_id` to the workspace when creating the job:
196204

@@ -212,9 +220,11 @@ A *worker process* is a long-running process, implemented as a Django management
212220

213221
Jobs are configured in the Django `settings.py` file. The `JOBS` setting is a dictionary mapping a *job name* (eg `import_cats`) to a *list* of one or more task function paths. For example:
214222

215-
JOBS = {
216-
'import_cats': ['apps.cat_importer.import_cats.step_one', 'apps.cat_importer.import_cats.step_two'],
217-
}
223+
```python
224+
JOBS = {
225+
'import_cats': ['apps.cat_importer.import_cats.step_one', 'apps.cat_importer.import_cats.step_two'],
226+
}
227+
```
218228

219229
### Job states
220230

@@ -263,7 +273,9 @@ to ensure the jobs table remains at a reasonable size.
263273
##### manage.py worker
264274
To start a worker:
265275

266-
manage.py worker [queue_name] [--rate_limit]
276+
```
277+
manage.py worker [queue_name] [--rate_limit]
278+
```
267279

268280
- `queue_name` is optional, and will default to `default`
269281
- The `--rate_limit` flag is optional, and will default to `1`. It is the minimum number of seconds that must have elapsed before a subsequent job can be run.

0 commit comments

Comments
 (0)