Just to throw it out there... forget about trying to make something
happen every ten minutes; or whatever your margin for error is.
Instead focus on just testing to see whether two hours have passed
when you come to use it. Either lazy (C), or diligent (D)...

Solution C:
Do nothing at all until someone comes asking for it: Have two hours
passed since the create_time? Yes. Trash. Sorry, you were too slow.

Solution D:
Every time someone comes asking for that object: Wait, let me just
trash everything i have which is over two hours old... ok. Now may I
help you? Oh, I'm sorry I don't have that anymore, maybe it expired.

(C) could lead to lots of dead stuff lying around whereas (D) could
lead to a lot of unnecessary overhead.
But for lightly loaded apps they'll do the job without the hassle.

Just for fun.

On Dec 13, 9:58 am, Tim Daniel <redarrow...@hotmail.com> wrote:
> Just want to figure out if there is a smarter solution for handling
> the following problem:
>
> 1. An action is performed by a user (Normal django behaviour handling
> a request and giving a response).
> 2. Two hours later I want an automatic action to be done.
>
> Solution A: Have a datetime field with an expiry date and say every 10
> minutes a cron job checks the DB table for expired entries and
> performs the programed action.
>
> Solution B: Have an event triggered cronjob that only executes once
> and is created from Django(Python), after the 2 hours passed it
> performs the programmed action only on the required entry.
>
> So how can I implement solution B? Is there a posibility to create a
> cron on a user action that executes only one time?
>
> NOTE: I don't want to rely on a thread that should stay alive for two
> hours ore more inside the server memory.

--

You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.


Reply via email to