Creating a job scheduler in a Django project

Поділитися
Вставка
  • Опубліковано 26 січ 2025

КОМЕНТАРІ • 77

  • @onyilimba
    @onyilimba Рік тому +2

    Just found this. it's awesome. been scratching my head since celery doesn't support windows. Thanks!

    • @DidCoding
      @DidCoding  Рік тому +1

      No worries. Glad the video was helpful

  • @patild4
    @patild4 8 місяців тому +1

    I cant thank you enough. I have been banging my head after many libraries but this one's miracle. 🙏

  • @JoshFlorii
    @JoshFlorii 2 роки тому +1

    your face zooming at me at 7:37 was low key terrifying, but good video

    • @DidCoding
      @DidCoding  2 роки тому

      😂😂 brilliant!
      I was experimenting with editing back when I put this one together.
      Thanks for the feedback

  • @arifshariar5290
    @arifshariar5290 Рік тому +1

    Awesome video, I was looking for a simpler solution and this video was just spot on!

    • @DidCoding
      @DidCoding  Рік тому

      Thanks for the feedback 🙌

  • @davidrosen2705
    @davidrosen2705 3 роки тому +1

    i like how you did your explanation you just explained your code)), i think its a fresh look from all the follow along tutorials i like it keep it up.

    • @DidCoding
      @DidCoding  3 роки тому

      Haha. Yeah, my typing is rubbish so it’s best to just explain the code & logic 😀

  • @ЄгорГашкодьор
    @ЄгорГашкодьор Рік тому +2

    great job,man you saved my project thanks a lot

  • @patientprogrammer00
    @patientprogrammer00 Рік тому +1

    great stuff. It truly made my evening!

  • @adhy612000151
    @adhy612000151 5 місяців тому

    thanks good man!!!! at last found this method!

  • @greensinais_bots
    @greensinais_bots 3 роки тому +3

    Thanks from Brazi!

  • @Md.Jakaria-z7s
    @Md.Jakaria-z7s 4 місяці тому

    Thanks for the video. But I have faced wired issue like- If i have multiple process running, then it calls multiple time the scheduler. Basically i was making logs for the scheduler functions then it was creating multiple time same log. So need to handle this thing, when using this scheduler approach.

  • @abduljabbarthameem8924
    @abduljabbarthameem8924 8 місяців тому +1

    Hi sir, this ready function is called twice in my case. So the job is executed twice. Can you suggest what may be the cause for this? (I guess there is an issue with the structure of the project) I’m new to django and I couldn’t find where the problem is getting initiated. I found that the app.py file is called twice by adding a pront statement inside it. Can you please help me in making the job scheduler run once?

    • @DidCoding
      @DidCoding  8 місяців тому

      Hi,
      I had this problem some time ago. It’s something todo with the workers.
      I always user a celery, beat and redis combo to handle tasks now. I’ve got a few videos on how to get it working. There is a short learning curve but it’s more robust.

  • @SuperWayneBruce
    @SuperWayneBruce Рік тому +1

    can you go over how we can integrate long running scripts (over 30 seconds) without interfering with the django site itself?

    • @DidCoding
      @DidCoding  Рік тому

      Hi there. Thanks for your message. I have stopped using this package as Celery has far more feature and is widely used commercially. You should check it out

  • @evalinor
    @evalinor 3 роки тому +2

    looks cool, i will try on my project instaed celery. Thanks

  • @pascalezeama7409
    @pascalezeama7409 2 роки тому +2

    Hello, thanks for this. My scheduler seems to be running twice each time the job is to be executed. what is the way out?

    • @DidCoding
      @DidCoding  2 роки тому +1

      Hi there. Yes, this is a pain! This stack overflow thread explains why this happens and how to get around it (stackoverflow.com/questions/39253537/apscheduler-is-executing-job-multiple-times). Also, I have put another video together on how to use Celery to schedule jobs (ua-cam.com/video/_9MbgyUvDGs/v-deo.html)

    • @pascalezeama7409
      @pascalezeama7409 2 роки тому

      @@DidCoding thank you

  • @supritkumar2624
    @supritkumar2624 3 роки тому +2

    If I am adding schedular start in apps.py file . It is calling twice at a time

    • @DidCoding
      @DidCoding  3 роки тому +1

      How strange! If you get your project on GitHub and send me a link I’ll have a quick look for you

    • @faberrocalv8958
      @faberrocalv8958 3 роки тому +1

      I had the same issue, and I solved it using Ibraheem's solution in my development environment, but when I deploy the app in production (Ubuntu server) using gunicorn (3 workers) and Nginx, the task is executed 3 times (maybe because the 3 workers), I read that it can be solved using Job store or something else but I don't understand how to do that. Someone know how to fix the problem in production? Thank you!

    • @DidCoding
      @DidCoding  3 роки тому

      It looks like my app needs some work. I’ll take a look and find a production fix.

  • @mohammadalqudah8044
    @mohammadalqudah8044 2 роки тому +1

    thanks , thanks ,
    it's easy to use , and work

    • @DidCoding
      @DidCoding  2 роки тому

      Thanks for your comment

  • @fatmakerouhkerouh379
    @fatmakerouhkerouh379 3 роки тому +1

    Hi, I have a question please, is it possible to link the execution to a specific app. Example, my first app is a log in app, than an other app where the user choose a third app. I want that the job starts when the user choose the third app. Is it possible to do that ? In my case, it starts immediately after manage.py runserver, even if I define ready(self) in the third app. Thank you for your amazing work!

    • @DidCoding
      @DidCoding  3 роки тому +1

      Hiya. I use APScheduler for basic routine function calls but it can handle more complex operations. I would suggest that you read the docs.
      Note: I will be putting a sequel together in the coming weeks that will be more comprehensive than this video.

  • @rtpictures6858
    @rtpictures6858 Рік тому +2

    Thaaaaaaaaannnnnnnkkkkkkkkkkkkkkk U!!!!!!!!!!!!!!!!!!!

  • @davidrosen2705
    @davidrosen2705 3 роки тому +1

    got a question, hope its not sound too stupid.. what are the difference between using a job scheduler and celery cons and pros using each, or are they totally different thank you

    • @DidCoding
      @DidCoding  3 роки тому

      Sorry for not seeing this comment!! The job scheduler is pretty light weight but is great for small projects. I would use Celery, Celery beat & Redis for large scale projects.

  • @RANJITHKUMAR-gs8wg
    @RANJITHKUMAR-gs8wg 2 роки тому +1

    i have 10 job scheduled in that i want to remove 5th and 6th jobschedule how to do it using APS?

    • @DidCoding
      @DidCoding  2 роки тому

      Sorry for the delay. Did you figure it out. I actually haven’t worked on APS for some time. I found celery & celery beat easier to use.

    • @RANJITHKUMAR-gs8wg
      @RANJITHKUMAR-gs8wg 2 роки тому

      thanks,
      do u know ansible-runner?@@DidCoding

  • @rohit_mondal__
    @rohit_mondal__ Рік тому +1

    Thanks a lot !

  • @ansari8114
    @ansari8114 6 місяців тому

    If Job function want a value than as parameter

  • @sondhi31
    @sondhi31 3 роки тому +1

    It's work if we just print a message, but unable to update database table!

    • @DidCoding
      @DidCoding  3 роки тому

      Oh really? That’s strange. Are you saving the new object?

    • @sondhi31
      @sondhi31 3 роки тому +1

      @@DidCoding Sorry it's was my fault. Due to some database flag columns, it does not update the table, when I wrote the comment. Later find out the issue was actually on my side, not the library itself. Btw, Thank you buddy for this helpful tutorial.

    • @DidCoding
      @DidCoding  3 роки тому

      @@sondhi31 No worries at all.

  • @demoproductions1839
    @demoproductions1839 2 роки тому +2

    It mostly works for me, it is a pity that the scheduled job runs twice eacht time :/

    • @DidCoding
      @DidCoding  2 роки тому

      Hi there. It’s because it runs with multiple workers. You should check out my celery video as this could be more suitable for your app.

  • @damilolasotomi886
    @damilolasotomi886 2 роки тому +1

    thank you for this video

    • @DidCoding
      @DidCoding  2 роки тому

      No worries. Thanks for the feedback

  • @faberrocalv8958
    @faberrocalv8958 3 роки тому +1

    Hi, thanks for the video. When I deploy the app in production (Ubuntu server) using gunicorn (3 workers) and Nginx, the task is executed 3 times (maybe because the 3 workers), I read that it can be solved using Job store or something else but I don't understand how to do that. Someone know how to fix the problem in production? Thank you!

    • @DidCoding
      @DidCoding  3 роки тому +1

      Hi Fernando. You are right. according to the documentation, a suggested workaround is to "run where the scheduler in a dedicated process and connect to it via some sort of remote access mechanism like RPyC, gRPC or an HTTP server." The link is: apscheduler.readthedocs.io/en/stable/faq.html#how-do-i-share-a-single-job-store-among-one-or-more-worker-processes

    • @faberrocalv8958
      @faberrocalv8958 3 роки тому +1

      @@DidCoding Thank you! I gonna read more about this. For now I found a solution tha is working for me without many complications, I wrote about it in an answer in the surprit kumar comment, you can check it for your validation!

    • @DidCoding
      @DidCoding  3 роки тому +1

      Thank you. I’ll be sure to have a look. I’ll put a sequel together with a robust workaround for production in the coming weeks👍

    • @priyankav.chaudhari62
      @priyankav.chaudhari62 3 роки тому

      @@faberrocalv8958 can you please share the link where you commented on the solution.

    • @faberrocalv8958
      @faberrocalv8958 3 роки тому +1

      @@priyankav.chaudhari62 Here is the link: stackoverflow.com/questions/16053364/make-sure-only-one-worker-launches-the-apscheduler-event-in-a-pyramid-web-app-ru/40162246#40162246
      The key is to use the flag --preload when you run gunicorn
      Also I configured this option for the scheduler as follows:
      job_defaults = {
      'coalesce': True,
      'max_instances': 1
      }
      scheduler = BackgroundScheduler(job_defaults=job_defaults)
      I put the updater.start() in the wsgi.py

  • @openclass4all
    @openclass4all 3 роки тому +1

    super, thanks sir 👍

  • @md.shifullah8261
    @md.shifullah8261 3 роки тому +1

    I have done this to my django project, but not working :(

    • @DidCoding
      @DidCoding  3 роки тому

      Does it not work at all or does it run multiple times as per some of the previous comments?

  • @jairajsahgal7101
    @jairajsahgal7101 Рік тому +1

    Thank you

  • @slikful
    @slikful 3 роки тому +1

    Tried this but nothing is happening. I am using Windows.

    • @DidCoding
      @DidCoding  3 роки тому

      Hi there. You will need to give me more detail on the issue you have for me to help.
      Thanks
      Bobby

  • @zackplauche
    @zackplauche Рік тому +1

    This isn't a calendar like the thumbnail showed 🤦‍♂

    • @DidCoding
      @DidCoding  Рік тому

      Correct. The video demonstrates how to create a job scheduler in Django 👍

  • @lestermorales782
    @lestermorales782 3 місяці тому

    Un idolo

  • @pratyushbehere3580
    @pratyushbehere3580 3 роки тому +1

    Thanks

  • @pankajpalariya4907
    @pankajpalariya4907 3 роки тому +1

    raise ValueError('The following arguments have not been supplied: %s' %
    ValueError: The following arguments have not been supplied: request
    this error is rising, in
    scheduler.add_job(scheduleT, 'interval' , seconds=5)
    May you help me please.

    • @DidCoding
      @DidCoding  3 роки тому +1

      Hi, I’m on vacation at the moment. However, if you send an invite to your git repo to bobby@didcoding.com, I’ll take a look when I have a second

    • @pankajpalariya4907
      @pankajpalariya4907 3 роки тому

      @@DidCoding send me your email id.... my git hub is currently not working