Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7860903
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T22:29:10+00:00 2026-06-02T22:29:10+00:00

An interesting conundrum. Here’s what I want to do: I have a Pyramid (python

  • 0

An interesting conundrum. Here’s what I want to do:

I have a Pyramid (python 2.7.2) website running on Heroku which pushes notifications to my iPhone app users. Each day, every user needs a push notification sent to them at a randomly generated time between 10:00am and 10:00pm (it obviously needs to know the users timezone as well).

My current plan is the following: Use a persistent worker process to trigger a function every 1 minute on the minute. Each minute, it will call a function (on a different thread so as not to interrupt the timer) which will do 2 things:

  1. Check if it’s 11:00pm for each timezone (which will happen 24 times a day, once for each timezone). If true, it will call a function which loops through every user in that respective timezone and generates their random time for the next day, then stores it in the Mongo database.

  2. On each minute, the worker will also loop through the users and check if they have their notification due at that time. If it’s due, then send the notification.

My question is: Is there a better way of doing this that doesn’t require generating a huge list of random datetimes every day beforehand?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T22:29:12+00:00Added an answer on June 2, 2026 at 10:29 pm

    There are certainly other ways. Whether they’re better is a different matter. For instance: suppose there are n minutes left before the end of a given user’s day and they haven’t had their notification yet. Then send them a notification now with probability 1/n. This way, you don’t need the huge list of random datetimes, but every minute you still need to iterate over all your users, see whether they’ve been notified yet, and compute random numbers for them all. It’s a little more computation in total (though I doubt the difference is significant) and means that all your database updates are small.

    Or: Each time you notify a user, then you generate their next update time. That way, the next-update times get computed incrementally but are still known in advance.

    (If your number of users is relatively small, so that on most minutes there isn’t a notification, you can make the scheduling smarter — but I won’t say more about that, because if you have that few users then the amount of work your software needs to do is going to be negligible anyway and there’s no point optimizing for that case.)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So here's an interesting conundrum. I have a page, default.aspx. It has a LINK
I have an interesting conundrum which I believe can be solved in purely SQL.
This is an interesting conundrum. We have a WPF app that has a Vista-like
Interesting one here. I have an ASP.NET 1.1 project that contains a web service
I have an interesting conundrum. We have a site that is a completely separate
Interesting one, this. I have the following JS code, which I'm displaying in a
I have interesting question. Do you know of any component to read/write PVRTC iPhone
I've got an interesting problem. I have an iPad App which has to parse
I have an interesting conundrum. I can create the type of chart I seek
I have interesting thing here, I'm using xcode 4 for my project and I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.