<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -20,7 +20,7 @@ class Client(object):
         self.scheduler = sched.scheduler(timefunc, delayfunc)
         self.scheduler.enter(config.SELF_CHECK_EVERY, 1, self.controller, ())
 
-        self.jobs = {}
+        self.jobs = []
 
     def controller(self):
         &quot;&quot;&quot;
@@ -42,24 +42,29 @@ class Client(object):
         &quot;Add a new check job&quot;
         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, ))
+        # append a job to the job list, it's sequence number identifies it
+        # (which happens to match to len(self.jobs) - 1 after an append)
+        self.jobs.append(job)
 
-    def runJob(self, name):
+        self.scheduler.enter(job.delay, 1, self.runJob, (len(self.jobs) - 1, ))
+
+    def runJob(self, jobnum):
         &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
+        print &quot;[run %s]&quot; % self.jobs[jobnum].name
         # TODO: run the real job
 
         # reschedule the job if requested
-        if self.jobs.has_key(name) and self.jobs[name].repeat:
+        if self.jobs[jobnum] and self.jobs[jobnum].repeat:
             self.scheduler.enter(
-                    self.jobs[name].delay, # delay in seconds
+                    self.jobs[jobnum].delay, # delay in seconds
                     1,                     # priority (unused)
-                    self.runJob, (name, )) # job's name
+                    self.runJob, (jobnum, )) # job's name
+        else:
+            # else delete the job from the job list
+            self.jobs[jobnum] = None
 
     def run(self):
         &quot;Run the client&quot;</diff>
      <filename>lightmon/client/client.py</filename>
    </modified>
    <modified>
      <diff>@@ -9,7 +9,7 @@ def run():
     &quot;&quot;&quot;
     cl = client.Client()
 
-    job = Job(&quot;test job&quot;, delay=20, repeat=True)
+    job = Job(&quot;test job&quot;, delay=10, repeat=True)
     cl.addJob(job)
 
     try:</diff>
      <filename>lightmon/client/runner.py</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>7a4f672f4ae07560114cf9b4e317d4293f7a6804</id>
    </parent>
  </parents>
  <author>
    <name>Ivan Giuliani</name>
    <email>giuliani.v@gmail.com</email>
  </author>
  <url>http://github.com/kratorius/lightmon/commit/36d1128347aae45099b1b0e1807c3125485dd94c</url>
  <id>36d1128347aae45099b1b0e1807c3125485dd94c</id>
  <committed-date>2009-11-04T04:46:55-08:00</committed-date>
  <authored-date>2009-11-04T04:46:55-08:00</authored-date>
  <message>Use a numbered sequence list for keeping track of jobs</message>
  <tree>308f407e775cb3a2ea3259c473f834a6d7e7e2fc</tree>
  <committer>
    <name>Ivan Giuliani</name>
    <email>giuliani.v@gmail.com</email>
  </committer>
</commit>
