From 2fb3f7e2bf2c444707ce5a81f0b54260d240f4bf Mon Sep 17 00:00:00 2001 From: Mark Wooding Date: Sun, 28 May 2017 19:03:08 +0100 Subject: [PATCH 1/1] rhodes: Clear out debris from stale workers in `check'. Doing this in every `step' leads to contention over the database, which currently isn't handled well. --- rhodes | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/rhodes b/rhodes index 4d30aea..092e97a 100755 --- a/rhodes +++ b/rhodes @@ -193,6 +193,17 @@ def check(dir): if not G.idp(G.pow(x, m)): bad('x not in group: %s^%d /= 1' % (G.str(x), m)) + ## Clear away old workers that aren't doing anything useful any more. + ## For each worker pid, check that its lockfile is still locked; if + ## not, it's finished and can be disposed of. + c.execute("""SELECT pid FROM workers""") + for pid, in c: + maybe_cleanup_worker(dir, db, pid) + for f in OS.listdir(dir): + if f.startswith('lk.'): + pid = int(f[3:]) + maybe_cleanup_worker(dir, db, pid) + c.execute("""SELECT p.p, p.e, p.k, p.n, p.dpbits, COUNT(d.z) FROM progress AS p LEFT OUTER JOIN points AS d ON p.p = d.p AND p.k = d.k @@ -309,17 +320,6 @@ def step(dir, cmd, *args): G, g, x, m, n = get_top(db) if n is not None: raise ExpectedError, 'job done' - ## Clear away old workers that aren't doing anything useful any more. - ## For each worker pid, check that its lockfile is still locked; if - ## not, it's finished and can be disposed of. - c.execute("""SELECT pid FROM workers""") - for pid, in c: - maybe_cleanup_worker(dir, db, pid) - for f in OS.listdir(dir): - if f.startswith('lk.'): - pid = int(f[3:]) - maybe_cleanup_worker(dir, db, pid) - ## Find something to do. Either a job that's small enough for us to ## take on alone, and that nobody else has picked up yet, or one that ## everyone's pitching in on. -- 2.11.0