<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array">
    <added>
      <filename>lightmon/jobs.py</filename>
    </added>
  </added>
  <modified type="array">
    <modified>
      <diff>@@ -8,6 +8,7 @@ import sched
 import time
 
 from lightmon import config
+from lightmon import jobs
 
 class Client(object):
     &quot;&quot;&quot;
@@ -19,12 +20,15 @@ class Client(object):
         self.scheduler = sched.scheduler(timefunc, delayfunc)
         self.scheduler.enter(config.SELF_CHECK_EVERY, 1, self.controller, ())
 
+        self.jobs = {}
+
     def controller(self):
         &quot;&quot;&quot;
         Control if there are stale threads that needs to be killed
         &quot;&quot;&quot;
         # reschedule ourselves every SELF_CHECK_EVERY seconds
-        self.checkJobs()
+        # self.checkJobs()
+        print &quot;not yet: controller&quot;
         self.scheduler.enter(config.SELF_CHECK_EVERY, 1, self.controller, ())
 
     def checkJobs(self):
@@ -34,9 +38,25 @@ class Client(object):
         &quot;&quot;&quot;
         raise NotImplementedError
 
-    def addJob(self):
+    def addJob(self, job):
         &quot;Add a new check job&quot;
-        raise NotImplementedError
+        assert isinstance(job, jobs.Job)
+
+        # XXX: the name might not be the best thing as an index due to collisions
+        self.jobs[job.name] = job
+        self.scheduler.enter(job.delay, 1, self.runJob, (job.name, ))
+
+    def runJob(self, name):
+        &quot;&quot;&quot;
+        Runs a job. This method gets called by the scheduler and might be
+        killed if it takes too much time.
+        &quot;&quot;&quot;
+        print &quot;[run %s]&quot; % name
+        # TODO: run the real job
+
+        # reschedule the job if requested
+        if self.jobs.haskey(name) and self.jobs[name].repeat:
+            self.scheduler.enter(self.jobs[name], 1, self.runJob, (name, ))
 
     def run(self):
         &quot;Run the client&quot;</diff>
      <filename>lightmon/client/client.py</filename>
    </modified>
  </modified>
  <removed type="array">
    <removed>
      <filename>lightmon/checks.py</filename>
    </removed>
  </removed>
  <parents type="array">
    <parent>
      <id>0350f6b81ef1ecb1ae7b22073ab168806e22a0be</id>
    </parent>
  </parents>
  <author>
    <name>Ivan Giuliani</name>
    <email>giuliani.v@gmail.com</email>
  </author>
  <url>http://github.com/kratorius/lightmon/commit/f06490cae2ca4f9f8b51fe920148c593d63fc7dd</url>
  <id>f06490cae2ca4f9f8b51fe920148c593d63fc7dd</id>
  <committed-date>2009-11-03T15:18:30-08:00</committed-date>
  <authored-date>2009-11-03T15:18:30-08:00</authored-date>
  <message>Narrowed down some logic about job addition</message>
  <tree>63a17e6ded66364861e768f350f60f08c85a047f</tree>
  <committer>
    <name>Ivan Giuliani</name>
    <email>giuliani.v@gmail.com</email>
  </committer>
</commit>
