Giter Club home page Giter Club logo

dj-tasks's Introduction

dj-tasks

A django app to run a collection of tasks in a management command.

Documentation

The full documentation is at https://dj-tasks.readthedocs.io.

Quickstart

Install dj-tasks:

pip install dj-tasks

Add it to your INSTALLED_APPS:

# project/settings.py
INSTALLED_APPS = [
    ...
    'dj_tasks',
    ...
]

Create a task:

# your_app/tasks.py
from dj_tasks.tasks import Task


class YourTask(Task):

    name = "Your Task"
    frequency = 60

    def run(self):
        print("Your custom code...")

Add to your DJTASKS_TASKS settings:

# project/settings.py
DJTASKS_LOCK_ID = "your_django_project"
DJTASKS_TASKS = [
    "your_app.tasks.YourTask",
]

Running Tests

Does the code actually work?

$ make install-dev
$ make lint
$ make test

Credits

Tools used in rendering this package:

dj-tasks's People

Contributors

cfc603 avatar

Stargazers

Andreas Motl avatar Nikolaus Schlemm avatar

Watchers

 avatar

dj-tasks's Issues

Delete old task entries

Each task run has an entry in TaskRun which, depending on the frequency of the app, could have thousands of past unneeded entries stored in the database.

Need to update run_tasks command to automatically delete entries over a certain period of time. One thought would be to have DJTASKS_DELETE_INTERVAL setting with expectation of int to translate to a number of days old. Default to 14 days.

2006, 'MySQL server has gone away'

Description

Setting DJTASKS_SLEEP_INTERVAL to 600 causes MySQLdb._exceptions.OperationalError: (2006, 'MySQL server has gone away') on PythonAnywhere deployment.

What I Did

Per docs at https://help.pythonanywhere.com/pages/ManagingDatabaseConnections/, a long running management command with five minutes or more between queries will cause this error due to the connection closing.

Need to close database connecting in between each run.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.