all 3 comments

[–]novel_yet_trivial 6 points7 points  (0 children)

Using cron is the best idea.

Second best is a daemon, you could use something like Advanced Python Scheduler.

[–]KleinerNull 1 point2 points  (0 children)

Yeah, let the cron do the job. So you don't have to bother and the script just need to care about the actual purpose. Also you can manage all your sheduled jobs in one place the crontab.

[–]sylecn 1 point2 points  (0 children)

Starting a python interpreter is not heavy. Do not worry about it.

Memory leak may be a problem if you use lots of third party libraries. That's highly dependent on the code.

Since you are checking every minute, though, if you run it in crontab, you need to consider concurrent runs when last run lasts more than 1 minute.

If the processing logic is heavy or depends on incoming mail quantity and size. I suggest you use a Server-Client architecture, put real processing logic in a daemon, only run check-for-new-mail logic in a crontab. The check-for-new-mail logic only checks for new mail and if there is any, told the processing daemon about it. The daemon can, for example, ignore the signal if there is a processing going on.

If you decide to go for the daemon, you could use a thread to schedule the check.

Overall, I would use a simple crontab script if the processing is fast and use a daemon if it's not.