10/26/2023 0 Comments Django scheduler![]() ![]() ![]() Handful of tasks on a fixed execution schedule. The ideal use case probably involves running a With minimal dependencies and very little additional configuration. It enables storing persistent jobs in theĭjango-apscheduler is a great choice for quickly and easily adding basic scheduling features to your Django applications So this may or may not be a good option depending on your use-case and securtity/dependency concerns.This is a Django app that adds a lightweight wrapper around APScheduler. This approach feels like having a third-party cron job with easier set-up :/ The push-notifications from the python-based back-end was pretty straightforward as specified in exponent-server-sdk-python. The app is made using React-Native and Expo and uses Expo's own Push-Notification features. Poll_max_time = timezone.now() + timedelta(minutes=PING_INTERVAL_MINUTES) # Use some Auth to identify requests coming from ping-service def get( self, request, *args, **kwargs): models import BookedMovieNotificationĭef send_booked_movie_reminder( notification: BookedMovieNotification) -> None:Ĭlass BookedMovieReminderAPIView( APIView): Then I reserved an endpoint for receiving pings, polling the DB and sending notifications. On_delete=models.CASCADE, null= False, blank= False) Movie_request = models.ForeignKey(MovieRequest, related_name= 'notifications', Rejected = models.BooleanField(default= False)Ĭlass BookedMovieNotification( models.Model): Time = models.TimeField(null= False, blank= False)Īccepted = models.BooleanField(default= False) Since I wasn't going to have a separate server for storing the notifications' data, I needed a table for that in my back-end and made a simple model: class MovieRequest( models.Model):ĭate = models.DateField(null= False, blank= False) I tried a few and finally settled for Uptime-Doctor which was perfect for me, as it provides free service for a few endpoints and I had a need for only 3. What they basically do is to just hit a particular endpoint at regular (short) intervals, and some can even store the logs, responses, and even provide some insights from that data. I started looking for options/alternatives if there is a solution already implemented (hopefully in a better way) and the concept of ping-services caught my attention. Also, having a separate (and dedicated) server also requires proper checks and a few other overheads at both the main back-end server and notification-server in case of revoked notifications (cancellation of booked movies). This is VERY simple to use, but it requires an extra (long-running) process, which again, was sort of having cron jobs. I wrote the code for the notification server, which uses django-background-tasks at its core. ![]() My first plan was to have a custom 'notification server' which would also act as a separate datastore for my booked-movie-reminders. The pings act as a trigger at my back-end server to poll the DB for all scheduled notifications which lie within the following ping interval and send all of them. TLDR I maintain a table at my back-end server to store scheduled notifications. Just simple sending scheduled notifications.įor what: To send a reminder (notifications) of upcoming booked-movie. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |