def main(): """Main code for worker.""" while True: start = time.time() subs_iter = repository.isubscriptions() while True: try: sub = subs_iter.next() except StopIteration: print 'All subs processed in {} seconds'.format( round(time.time() - start, 2)) break if sub is None: break sub_id, sub_detail = sub try: process_sub(sub_id, sub_detail) except: print u'Skipping {}, exception:\n {}'.format( sub_id, traceback.format_exc()) time.sleep(1) time.sleep(datetime.timedelta(minutes=15).total_seconds())
def main(): """Main code for worker.""" while True: subs_iter = repository.isubscriptions() while True: try: sub = subs_iter.next() except StopIteration: print 'All subs processed' break if sub is None: break sub_id, sub_detail = sub try: process_sub(sub_id, sub_detail) except: print 'Skipping {}, exception:\n {}'.format( sub_id, traceback.format_exc() ) time.sleep(1) time.sleep(60)
def increment_email_sub_deltas(): """Add/increment domains found in delta reports for email subs. Return count of updated domains. """ updated_domains = set() subs_iter = repository.isubscriptions() while True: try: sub = subs_iter.next() except StopIteration: break sub_detail = sub[1] domain = sub_detail['domain'] updated_domains = process_domain(domain, updated_domains) return updated_domains
) # Mark as emailed to ensure we don't flood if there's an error after the # actual email has been sent. repository.update_last_email_sub_sent_date(sub_id) emailer.send( email_address, 'dnstwister report for {}'.format(domain), body ) print 'Emailed delta for {} to {}'.format(domain, email_address) if __name__ == '__main__': while True: subs_iter = repository.isubscriptions() while True: try: sub = subs_iter.next() except StopIteration: print 'All subs processed' break if sub is None: break sub_id, sub_detail = sub try: