Skip to content

Commit

Permalink
Update README for actual usage
Browse files Browse the repository at this point in the history
  • Loading branch information
vanschelven committed Sep 5, 2024
1 parent cba739d commit 6121526
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 3 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,7 @@ __pycache__
# vim
*.swo
*.swp


# sqlite
/example_django_project/*sqlite3*
50 changes: 47 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,50 @@ A simple alternative for celery that doesn't require a broker.

See https://www.bugsink.com/snappea-design/

NOTE: as it stands, this code is provided as an example. It was simply
extracted from another codebase, and can be studied. But I have no expectation
that it will "just run" as is.
Django-only, Linux-only.

### Usage:

1. Add `snappea` to your `INSTALLED_APPS`.

2. Add a "snappea" DATABASE to your settings, and route snappea traffic to it:

```
DATABASES = {
[..]
"snappea": {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': BASE_DIR / 'snappea.sqlite3',
'OPTIONS': {
'timeout': 5,
},
},
}
DATABASE_ROUTERS = ("snappea.dbrouters.SeparateSnappeaDBRouter",)
```

3. Create the tables:

```
python manage.py migrate --database=snappea
```

4. Start the snappea background process:

```
python manage.py runsnappea
```

5. In another Window, fire off a task to test that it works:

```
python manage.py shell
Python [..] (main, [..]
Type "help", "copyright", "credits" or "license" for more information.
(InteractiveConsole)
>>> from snappea.example_tasks import *
>>> fast_task.delay()
```
5 changes: 5 additions & 0 deletions snappea/example_tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,8 @@ def failing_task():
@shared_task
def fast_task():
pass


@shared_task
def printing_task():
print("Printing something")

0 comments on commit 6121526

Please sign in to comment.