django-flexible-subscriptions icon indicating copy to clipboard operation
django-flexible-subscriptions copied to clipboard

Enhancement: Improve documentation to describe how to setup task scheduler

Open studybuffalo opened this issue 7 years ago • 4 comments

Update documentation to describe how to setup and integrate application with a task scheduler (e.g. Celery).

studybuffalo avatar Dec 25 '18 23:12 studybuffalo

I think the manager system could be entirely replaced with the sched module. It will omit the complexity of a task scheduler. https://docs.python.org/3/library/sched.html

HosseyNJF avatar Jan 15 '20 09:01 HosseyNJF

I took some time to look through this. It looks like it could technically work, but I am not sure I want to get this package into the complexity of task management. That said, if this is a feature that users are requesting/will find valuable, we could look into it further.

Some initial requirements up front:

  • I think this needs to be optional and easy to use/not use
  • In all implementations, I think we need to keep using subscriptions/management/commands/_manager.py to maintain and test all logic.

Two ways to meet the above requirements off the top of my head:

  • Update documentation to show people how to build their own scheduler with sched - this lets people know it is an options and how to use it quickly and easily. They can make the choice to make it more robust for their needs.
  • Implement it as a second Django app that users can choose to include or not. We'd need to consider how to best implement that in terms of file structure, testing, etc.

From a personal perspective, this is not something I am going to have time to implement robustly, so I probably am not going to do this. If you (or anyone else) is interested in taking this up, we can chat further on this issue here and determine the best approach (i.e. I don't want anyone to do all this work and then have the pull request rejected).

studybuffalo avatar Jan 16 '20 14:01 studybuffalo

From my perspective, as a user of this library, it is definitely better to just let the library process events and notifying relevant manager functions than having to set-up and maintain my own schedule system; which is usually Cron on Linux having a precision of 1 minute - it means you can't be sure your task runs on the required second, only at the same minute without using Cron hacks.

It doesn't have to be optional; In fact, we could use it as the main way to run the Manager and deprecate the old system for backward compatibility.

Most of the system would be untouched - The same Manager that should be extended with the same event functions. We only have to do these things:

  • Deprecate process_subscriptions.py file and process_subscriptions function in the _manager.py file.
  • Fetch all subscriptions due times and schedule events for corresponding subscriptions and times on app start (For subscriptions that were in the database before the app ran)
  • Schedule new subscriptions that get inserted while the app is running

And it should do it, at least minimally to get it working.

HosseyNJF avatar Jan 16 '20 17:01 HosseyNJF

I'll open a new issue because this one isn't relevant.

HosseyNJF avatar Jan 16 '20 17:01 HosseyNJF