import json

NULL_CHAR = b"\x01"

class Job(object):

    def __init__(self, workload, client):
        workload = workload.split(NULL_CHAR)
        self.workload = json.loads(str(workload[0], "UTF-8"))
        self.job_handle = str(workload[1], "UTF-8")
        self.client = client


    def __getattr__(self, key):
        return self.workload.get(key)


    def get(self, key, default=None):
        return self.workload.get(key, default)


    def done(self):
        yield from self.client.send(["done", self.job_handle])


    def sched_later(self, delay):
        yield from self.client.send(["sched_later", self.job_handle,str(delay)])


    def fail(self):
        yield from self.client.send(["fail", self.job_handle])

@@ -283,80 +283,8 @@
 t%0A%0A%0A
-    def __getattr__(self, key):%0A        return self.workload.get(key)%0A%0A%0A
     
@@ -317,16 +317,16 @@
 =None):%0A
+
         
@@ -580,32 +580,32 @@
 def fail(self):%0A
-
         yield fr
@@ -631,28 +631,446 @@
 (%5B%22fail%22, self.job_handle%5D)%0A
+%0A%0A    @property%0A    def func_name(self):%0A        return self.workload%5B'name'%5D%0A%0A%0A    @property%0A    def name(self):%0A        return self.workload.get(%22name%22)%0A%0A%0A    @property%0A    def sched_at(self):%0A        return self.workload%5B%22sched_at%22%5D%0A%0A%0A    @property%0A    def timeout(self):%0A        return self.workload.get(%22timeout%22, 0)%0A%0A%0A    @property%0A    def run_at(self):%0A        return self.workload.get(%22run_at%22, self.sched_at)%0A

update job property