Fix job interruption a bit

This commit is contained in:
Oleksii Shevchuk 2018-03-10 22:18:52 +02:00
parent 164c5410e5
commit 0ba516df2e
1 changed files with 16 additions and 5 deletions

View File

@ -80,6 +80,7 @@ class ThreadPool(object):
t.stop()
def join(self):
giveup = False
while True:
try:
allok=True
@ -89,14 +90,19 @@ class ThreadPool(object):
allok=False
if allok:
break
except KeyboardInterrupt:
print "Press [ENTER] to interrupt the job"
pass
if not giveup:
print "{ Press ^C once again to give up on waiting }"
giveup = True
else:
break
def all_finished(self):
for t in self.thread_pool:
if t.isAlive():
return False
return True
class PupyJob(object):
@ -212,12 +218,17 @@ class PupyJob(object):
break
try:
m.client.conn._conn.ping(timeout=2)
m.client.conn._conn.ping(timeout=2, block=True)
logging.info('connection {} alive'.format(m))
break
except KeyboardInterrupt:
continue
except (rpyc.AsyncResultTimeout, ReferenceError, EOFError):
logging.debug("connection %s seems blocked, reinitialising..."%str(m))
except (rpyc.AsyncResultTimeout, ReferenceError, EOFError), e:
logging.error('connection {} seems blocked ({}), reinitialising...'.format(
m.client.short_name(), e))
try:
m.client.conn._conn.close()
except (rpyc.AsyncResultTimeout, ReferenceError, EOFError):