Zaki Akhmad <zakiakh...@gmail.com> Wrote in message: > On Thu, Feb 20, 2014 at 7:39 PM, James Scholes <ja...@jls-radio.com> wrote: > >> Most decent Python libraries for accessing Twitter support the streaming >> API. This lets you keep a connection to the Twitter API alive and >> process new data as it is received. There is a simple (but out-of-date) >> example on using streaming with the twitter package you linked to: >> https://pypi.python.org/pypi/twitter/1.13.1 > > My question is: how to execute this streaming API? > > My current approach is using cron to execute python script which has > "check the streaming API" function: > > def check_mention: > if (mention): > tweet > > If I want to check every minute, then I should configure cron to > execute this script every minute. Are there any other approach besides > using cron? > > > >
import time while True: do|something time.sleep (60) Note that sleep () doesn't hog the processor; very nearly 100% of the processor is given to the other processes. Further, you don't have the startup time you'd have with cron. There are tradeoffs, but sleep is usually what you want. -- DaveA _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor