Skip to content

Instantly share code, notes, and snippets.

@mitechie
Created July 18, 2011 03:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mitechie/1088511 to your computer and use it in GitHub Desktop.
Save mitechie/1088511 to your computer and use it in GitHub Desktop.
from Queue import Queue
class ShowQueue(object):
"""We need to implement the basics of Queue to use it"""
def __init__(self):
self.queue_store = Queue()
def qsize(self):
return self.queue_store.qsize()
def put(self, show):
"""Store this queue into the db, we want to track the time and the show id"""
ShowTracker.add(show)
self.queue_store.put(show)
def get(self):
"""Return the next item from the queue"""
return self.queue_store.get()
class ShowTrackerMgr(object):
def last_run(show_id):
# return result of MAX(id) WHERE show_id = show_id and run_or_skipped = run
pass
class ShowTracker(Base):
"""Data store for a log of our shows we're processing"""
id
show_id
run_or_skipped
tstamp
# so using this you'd do something like
q = ShowQueue()
LIMIT = datetime.now() + timedelta(hours=2)
for show in show_list:
q.put(show)
while q.qsize > 0:
show = q.get()
if ShowTrackerMgr.last_run < LIMIT:
pass
else:
# do whatever with the feeds
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment