Forums

Scheduling Task in Django Web App

I have a web app for PROPERTY MANAGEMENT that manages renters and their payments. I want to add a feature that sends a WhatsApp message to the renter, at a time specified by the user (Owner) from the UI. The time is generally 2 months prior, 1 month prior, and 1 day prior to the payment due date. I know celery is not supported in PythonAnywhere. Also, I am new to scheduling tasks on any platform. What should I do?

I can use Always On Tasks but is there a way to communicate the script running in always on task with the web app database? For example, the always-running script continuously fetches the information from the web app's database, which has a field containing information regarding the time and date on which the message needs to be sent. So this field is continuously fetched and checked against the current time on the server, if it matches then the message is sent. Tell me if this idea is possible here in the Always-On Task. It would be very helpful.

We have a help page that cover that here: https://help.pythonanywhere.com/pages/AsyncInWebApps/

Okay, I will check it out. BTW I am using a library for my purpose django-apscheduler and when using it I am getting an error

Error running WSGI application
RuntimeError: The scheduler seems to be running under uWSGI, but threads have been disabled. You must run  uWSGI with the --enable-threads option for the scheduler to work.

How to enable Threads? If threads can be enabled than my problem is solved. Why isnt pythonanywhere enabling asgi configuration or threads? This amounts to much more work beacuse in local server everything works but on pythonanywhere you need to find a different way to do that which consumes more time.

Also What is Django Q? Is it similar to other scheduling libraries like celery, etc? Is it supported in PythonAnyhwere?

You can't enable threads under uWSGI on PythonAnywhere, you'd need to delegate the threading code to a script running outside of the web app. Regarding ASGI -- we're working on it; regarding Django Q -- here are the docs.