Skip to content

Commit

Permalink
Merge pull request #920 from procrastinate-org/get_worker_connector
Browse files Browse the repository at this point in the history
  • Loading branch information
ewjoachim authored Feb 1, 2024
2 parents b91613e + 4ada597 commit a2d688e
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions docs/howto/django.md
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,26 @@ PERIODIC_DEFAULTS: dict | None, # (defaults to None)
Procrastinate logs to the `procrastinate` logger. You can configure it
in your `LOGGING` settings.

## Advanced: Running the worker without the official management command
If you want to run the worker yourself, it's possible but slightly more convoluted.
Here's how you could do it:
```python
# myapp/worker.py
from procrastinate.contrib.django import app

def main():
# By default, the app uses the Django database connection, which is unsuitable
# for the worker.
app = app.with_connector(app.connector.get_worker_connector())
app.run_worker()

if __name__ == "__main__":
main()
```
:::{note}
The ``.get_worker_connector()`` method is only available on `DjangoConnector`
and the API isn't guaranteed to be stable.

## Alternatives

It's worth noting that there are other Python job scheduling libraries based on
Expand Down

0 comments on commit a2d688e

Please sign in to comment.