From 17423b6646709d6f3a34c69c726e4d344b73560d Mon Sep 17 00:00:00 2001 From: david Date: Fri, 21 Mar 2014 04:05:47 -0700 Subject: [PATCH] small changes requested by forrest in gearman code. Change-Id: I611cad21cebe90b8d75a0d618804663d98108ab0 --- refstack/gearman.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/refstack/gearman.py b/refstack/gearman.py index 3d51b3df..ec3348fb 100755 --- a/refstack/gearman.py +++ b/refstack/gearman.py @@ -13,8 +13,9 @@ # under the License. import gear -import logging +from gear import GearmanError, TimeoutError import json +import logging import time from uuid import uuid4 @@ -61,7 +62,7 @@ class Gearman(object): try: self.gearman.submitJob(gearman_job) - except Exception: + except GearmanError: self.log.exception("Unable to submit job to Gearman") self.on_build_completed(gearman_job, 'EXCEPTION') #return build @@ -78,10 +79,13 @@ class Gearman(object): """called when test is completed""" if job.unique in self.meta_jobs: del self.meta_jobs[job.unique] - return + return result - def is_job_registered(self, name): + def is_job_registered(self, name=None): """ checks to see if job registered with gearman or not""" + if not name: + return False + if self.function_cache_time: for connection in self.gearman.active_connections: if connection.connect_time > self.function_cache_time: @@ -101,7 +105,7 @@ class Gearman(object): try: req = gear.StatusAdminRequest() connection.sendAdminRequest(req) - except Exception: + except TimeoutError: self.log.exception("Exception while checking functions") continue for line in req.response.split('\n'):