Permalink
Browse files

sleep in a longer interval if the db is locked.

retry 10x instead of 5 when encountering db errors
  • Loading branch information...
1 parent 66114ba commit e632c9f14e746b58c1c3ba3c320ce76511d9c977 BuzzTroll committed Oct 12, 2010
Showing with 5 additions and 4 deletions.
  1. +1 −1 lantorrent/pylantorrent/__init__.py
  2. +4 −3 lantorrent/pylantorrent/request.py
@@ -70,7 +70,7 @@ def set_defaults(self):
self.logfile = "lantorrent.log"
self.log_level = logging.DEBUG
self.dbfile = None
- self.db_error_max = 5
+ self.db_error_max = 10
self.insert_delay = 30
def load_settings(self, ini_file):
@@ -69,7 +69,7 @@ def is_done(con, rid):
error_cnt = error_cnt + 1
if error_cnt >= pylantorrent.config.db_error_max:
raise sqlex
- time.sleep(random.random())
+ time.sleep(random.random() * 2.0)
def delete_rid(con, rid):
error_cnt = 0
@@ -87,7 +87,7 @@ def delete_rid(con, rid):
error_cnt = error_cnt + 1
if error_cnt >= pylantorrent.config.db_error_max:
raise sqlex
- time.sleep(random.random())
+ time.sleep(random.random() * 2.0)
def request(argv, con):
src_filename = argv[0]
@@ -128,7 +128,7 @@ def request(argv, con):
error_ctr = error_ctr + 1
if error_ctr >= pylantorrent.config.db_error_max:
raise ex
- time.sleep(random.random())
+ time.sleep(random.random() * 2.0)
# should never get here
@@ -148,6 +148,7 @@ def main(argv=sys.argv[1:]):
"""
pylantorrent.log(logging.INFO, "enter")
+ random.seed()
(o, args, p) = setup_options(argv)

0 comments on commit e632c9f

Please sign in to comment.