Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding how to use builtin scheduler in README #209

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,36 @@ $ mrq-worker fetches

You can interrupt the worker with Ctrl-C once it is finished.

### Run it via the built-in scheduler

Create a `schedule.py` file with the following code:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you want you can just edit the default config file which is mrq-config.py


```
SCHEDULER_TASKS = [
{
"path": "fetches tasks.Fetch",
"params": {
"url": "http://www.google.com"
},
"queue": "fetch_queue",
"interval": 5 # Run every 5 seconds
}
]

SCHEDULER_INTERVAL = 0.1
```
Run the schedule using:

```
mrq-run --scheduler --config schedule.py
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here you should run a scheduler worker with mrq-worker --scheduler fetch_queue . This will spawn a [scheduler greenlet](https://github.com/pricingassistant/mrq/blob/master/mrq/worker.py#L141 that will run the scheduler every SCHEDULER_INTERVAL s)

```

Also start a queue to process the jobs scheduled by the scheduler:

```
mrq-worker fetch_queue
```

## Going further

This was a preview on the very basic features of MRQ. What makes it actually useful is that:
Expand Down