Example #1
0
    def execute(self):
        # TODO: Timeout concerns
        self.lock.acquire()

        # TODO: this can break in various ways on bad input
        task_type = wire.read_string(self.shmem)

        try:
            klass = _task_registry[task_type]
            task = klass(self.shmem)
            task.run()
        except:
            self.shmem.seek(0)

            # XXX: Failure indicator
            wire.write_uint8(self.shmem, 0)

            tb = traceback.format_exc()

            # HACK: Traceback string must be truncated so it will fit in the
            # shared memory (along with the uint32 length prefix)
            if len(tb) + 5 > len(self.shmem):
                tb = tb[:len(self.shmem) - 5]

            wire.write_string(self.shmem, tb)
        finally:
            self.lock.release()
Example #2
0
 def mark_failure(self):
     wire.write_uint8(self.shmem, 0)
Example #3
0
 def mark_success(self):
     wire.write_uint8(self.shmem, 1)