[copr] skvidal-backend: only spin up any workers if we have jobs (947827f)

skvidal at fedoraproject.org skvidal at fedoraproject.org
Fri Nov 16 14:50:58 UTC 2012


Repository : http://git.fedorahosted.org/cgit/copr.git

On branch  : skvidal-backend

>---------------------------------------------------------------

commit 947827fa5d0862aa57a46c438538df02c159b77d
Author: Seth Vidal <skvidal at fedoraproject.org>
Date:   Fri Nov 16 09:49:01 2012 -0500

    only spin up any workers if we have jobs


>---------------------------------------------------------------

 copr-be.py |   34 +++++++++++++++++-----------------
 1 files changed, 17 insertions(+), 17 deletions(-)

diff --git a/copr-be.py b/copr-be.py
index 9db9f17..fcf3f44 100644
--- a/copr-be.py
+++ b/copr-be.py
@@ -86,7 +86,6 @@ class CoprBackend(object):
 
         abort = False
         while not abort:
-            print 'adding jobs'
             for f in sorted(glob.glob(self.opts.jobsdir + '/*.json')):
                 n = os.path.basename(f).replace('.json', '')
                 if n not in self.added_jobs:
@@ -94,25 +93,26 @@ class CoprBackend(object):
                     self.added_jobs.append(n)
                     self.log('adding %s' % n)
 
-            # re-read config into opts
-            self.opts= self.read_conf()
-            # this handles starting/growing the number of workers
-            if len(self.workers) < self.opts.num_workers:
-                for i in range(self.opts.num_workers - len(self.workers)):
-                    w = Worker(self.opts, self.jobs)
-                    self.workers.append(w)
-                    w.start()
-            # FIXME - prune out workers
-            #if len(self.workers) > self.opts.num_workers:
-            #    killnum = len(self.workers) - self.opts.num_workers
-            #    for w in self.workers[:killnum]:
-            #       #insert a poison pill? Kill after something? I dunno.
-            # FIXME - if a worker bombs out - we need to check them
-            # and startup a new one if it happens
+            if self.jobs.qsize():
+                # re-read config into opts
+                self.opts = self.read_conf()
+                # this handles starting/growing the number of workers
+                if len(self.workers) < self.opts.num_workers:
+                    for i in range(self.opts.num_workers - len(self.workers)):
+                        w = Worker(self.opts, self.jobs)
+                        self.workers.append(w)
+                        w.start()
+                # FIXME - prune out workers
+                #if len(self.workers) > self.opts.num_workers:
+                #    killnum = len(self.workers) - self.opts.num_workers
+                #    for w in self.workers[:killnum]:
+                #       #insert a poison pill? Kill after something? I dunno.
+                # FIXME - if a worker bombs out - we need to check them
+                # and startup a new one if it happens
         
             self.log("# jobs in queue: %s" % self.jobs.qsize())
 
-        time.sleep(self.opts.sleeptime)
+            time.sleep(self.opts.sleeptime)
 
     
 def main(args):



More information about the copr-devel mailing list