def handle(self, **options): pid = Pid('mturk_diffs', True) transaction.enter_transaction_management() transaction.managed(True) start_time = time.time() try: for c in Crawl.objects.filter( is_spam_computed=False).order_by('-id')[:options['limit']]: updated = update_cid(c.id) if updated > 0: c.has_diffs = True c.save() transaction.commit() except (KeyError, KeyboardInterrupt): transaction.rollback() pid.remove_pid() exit() logger.info('updating 5 crawls took: %s s', (time.time() - start_time))
def handle(self, **options): pid = Pid('mturk_diffs', True) transaction.enter_transaction_management() transaction.managed(True) start_time = time.time() try: for c in Crawl.objects.filter(is_spam_computed=False).order_by('-id')[:options['limit']]: updated = update_cid(c.id) if updated > 0: c.has_diffs=True c.save() transaction.commit() except (KeyError, KeyboardInterrupt): transaction.rollback() pid.remove_pid() exit() logger.info('updating 5 crawls took: %s s', (time.time() - start_time))
def handle(self, **options): pid = Pid('mturk_diffs', True) transaction.enter_transaction_management() transaction.managed(True) start_time = time.time() try: items = Crawl.objects.filter(is_spam_computed=False ).order_by('-id')[:options['limit']] lenitems = len(items) log.info(('Starting db_update_diffs, {0} crawls will be updated.' ).format(lenitems)) for c in items: updated = update_cid(c.id) if updated > 0: c.has_diffs = True c.save() transaction.commit() except (KeyError, KeyboardInterrupt) as e: log.info(('Exception, rolling back the transaction and exiting: {0}' ).format(e)) transaction.rollback() pid.remove_pid() exit() log.info('Success! Updating {0} crawls took: {1} s'.format( lenitems, time.time() - start_time))