import yaml

from ssbench.constants import *

class Worker:
    def __init__(self, queue):
        queue.use(STATS_TUBE)
        self.queue = queue

    def go(self):
        job = self.queue.reserve()
        while job:
            job.delete()  # avoid any job-timeout nonsense
            self.handle_job(job)
            job = self.queue.reserve()


    def handle_job(self, job):
        job_data = yaml.load(job.body)
        if job_data['type'] == UPLOAD_OBJECT:
            print "WOO" # magic goes here
        else:
            print "BOO"
    

@@ -535,21 +535,66 @@
     
-print %22BOO%22%0A    
+raise NameError(%22Unknown job type %25r%22 %25 (job_data%5B'type'%5D,))%0A
 %0A

Raise error on unknown job type