fix how status is checked to avoid piling-on

This commit is contained in:
James Turk 2011-08-05 16:46:13 -04:00
parent 415dc44af2
commit 1b3330fa69
2 changed files with 7 additions and 3 deletions

View File

@ -22,6 +22,11 @@ class Client(object):
size=mongo_log_maxsize)
except pymongo.errors.CollectionInvalid:
pass
# create status document if it doesn't exist
if self.db.status.count() == 0:
self.db.status.insert({'update_queue': 0})
self._collection_name = 'fs'
self.fs = gridfs.GridFS(self.db, self._collection_name)
self.scraper = scrapelib.Scraper(user_agent=user_agent,
@ -40,6 +45,7 @@ class Client(object):
self.db.drop_collection('%s.chunks' % self._collection_name)
self.db.drop_collection('%s.files' % self._collection_name)
self.db.drop_collection('logs')
self.db.drop_collection('status')
def log(self, action, url, error=False, **kwargs):

View File

@ -6,8 +6,6 @@ from celery.execute import send_task
from oyster.client import Client
client = Client()
client.db.status.drop()
client.db.status.insert({'update_queue': 0})
@task(ignore_result=True)
@ -31,7 +29,7 @@ class UpdateTaskScheduler(PeriodicTask):
# (currently the only way we avoid duplicates)
# alternate option would be to set a _queued flag on documents
if client.db.status.find_one()['update_queue']:
pass
return
next_set = client.get_update_queue()
for doc in next_set: