diff options
author | martinko | 2013-10-02 12:39:52 +0000 |
---|---|---|
committer | martinko | 2013-10-02 12:39:52 +0000 |
commit | d16ff7ff2d43df26948f012ee3b436e3e94be8cb (patch) | |
tree | fd5b08900717b0236ff0a21fd5adf94e3e61ffdd | |
parent | ef31807f987fc3e3ae662d9d9ace7cbdff0cdb13 (diff) |
scripts/data_maintainer.py: clean-up
-rw-r--r-- | scripts/data_maintainer.py | 18 |
1 files changed, 5 insertions, 13 deletions
diff --git a/scripts/data_maintainer.py b/scripts/data_maintainer.py index ecb0c377..40a5f5a1 100644 --- a/scripts/data_maintainer.py +++ b/scripts/data_maintainer.py @@ -113,7 +113,7 @@ class DataMaintainer (skytools.DBScript): self.autocommit = self.cf.getint("autocommit", 1) # delay in seconds after each commit - self.commit_delay = self.cf.getfloat("commit_delay", 0.0) + self.commit_delay = self.cf.getfloat("commit_delay", 0.0) def work(self): self.log.info('Starting..') @@ -169,34 +169,26 @@ class DataMaintainer (skytools.DBScript): time.sleep(self.commit_delay) if time.time() - lap_time > 60.0: # if one minute has passed print running totals self.log.info("--- Running count: %s duration: %s ---", - total_count, datetime.timedelta(0, round(time.time() - started))) + total_count, datetime.timedelta(0, round(time.time() - started))) lap_time = time.time() rcur.execute("CLOSE data_maint_cur") if not self.withhold: dbr.rollback() self.log.info("--- Total count: %s duration: %s ---", - total_count, datetime.timedelta(0, round(time.time() - started))) + total_count, datetime.timedelta(0, round(time.time() - started))) if self.sql_after and (self.after_zero_rows > 0 or total_count > 0): adb = self.get_database("dbafter", autocommit=1) acur = adb.cursor() - - # FIXME: neither of those can be None? - if bres != None and lastitem != None: - bres.update(lastitem) - lastitem = bres - if lastitem != None: - acur.execute(self.sql_after, lastitem) - else: - acur.execute(self.sql_after) + acur.execute(self.sql_after, lastitem) def process_batch(self, res, mcur, bres): """ Process events in autocommit mode reading results back and trying to make some sense out of them """ try: count = 0 - item = bres + item = bres.copy() for i in res: # for each row in read query result item.update(i) mcur.execute(self.sql_modify, item) |