Skip to content
This repository has been archived by the owner on Sep 23, 2020. It is now read-only.

Commit

Permalink
sleep in a longer interval if the db is locked.
Browse files Browse the repository at this point in the history
retry 10x instead of 5 when encountering db errors
  • Loading branch information
BuzzTroll committed Oct 26, 2010
1 parent 66114ba commit e632c9f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion lantorrent/pylantorrent/__init__.py
Expand Up @@ -70,7 +70,7 @@ def set_defaults(self):
self.logfile = "lantorrent.log" self.logfile = "lantorrent.log"
self.log_level = logging.DEBUG self.log_level = logging.DEBUG
self.dbfile = None self.dbfile = None
self.db_error_max = 5 self.db_error_max = 10
self.insert_delay = 30 self.insert_delay = 30


def load_settings(self, ini_file): def load_settings(self, ini_file):
Expand Down
7 changes: 4 additions & 3 deletions lantorrent/pylantorrent/request.py
Expand Up @@ -69,7 +69,7 @@ def is_done(con, rid):
error_cnt = error_cnt + 1 error_cnt = error_cnt + 1
if error_cnt >= pylantorrent.config.db_error_max: if error_cnt >= pylantorrent.config.db_error_max:
raise sqlex raise sqlex
time.sleep(random.random()) time.sleep(random.random() * 2.0)


def delete_rid(con, rid): def delete_rid(con, rid):
error_cnt = 0 error_cnt = 0
Expand All @@ -87,7 +87,7 @@ def delete_rid(con, rid):
error_cnt = error_cnt + 1 error_cnt = error_cnt + 1
if error_cnt >= pylantorrent.config.db_error_max: if error_cnt >= pylantorrent.config.db_error_max:
raise sqlex raise sqlex
time.sleep(random.random()) time.sleep(random.random() * 2.0)


def request(argv, con): def request(argv, con):
src_filename = argv[0] src_filename = argv[0]
Expand Down Expand Up @@ -128,7 +128,7 @@ def request(argv, con):
error_ctr = error_ctr + 1 error_ctr = error_ctr + 1
if error_ctr >= pylantorrent.config.db_error_max: if error_ctr >= pylantorrent.config.db_error_max:
raise ex raise ex
time.sleep(random.random()) time.sleep(random.random() * 2.0)


# should never get here # should never get here


Expand All @@ -148,6 +148,7 @@ def main(argv=sys.argv[1:]):
""" """


pylantorrent.log(logging.INFO, "enter") pylantorrent.log(logging.INFO, "enter")
random.seed()


(o, args, p) = setup_options(argv) (o, args, p) = setup_options(argv)


Expand Down

0 comments on commit e632c9f

Please sign in to comment.