Remove the promise object for now

This commit is contained in:
Joshua Harlow
2013-05-13 14:11:51 -07:00
parent 5317465592
commit 153b5a460f
3 changed files with 9 additions and 51 deletions

View File

@@ -23,7 +23,7 @@ from taskflow import exceptions as exc
from taskflow import states
class JobClaimer(object):
class Claimer(object):
"""A base class for objects that can attempt to claim a given claim a given
job, so that said job can be worked on."""
@@ -57,6 +57,7 @@ class Job(object):
@property
def logbook(self):
"""Fetches (or creates) a logbook entry for this job."""
if self._logbook is None:
if self in self._catalog:
self._logbook = self._catalog.fetch(self)
@@ -83,6 +84,10 @@ class Job(object):
self.state = new_state
# TODO(harlowja): update the logbook
def await(self, blocking=True, timeout=None):
"""Attempts to wait until the job fails or finishes."""
raise NotImplementedError()
def erase(self):
"""Erases any traces of this job from its associated resources."""
for b in self.posted_on:

View File

@@ -21,7 +21,9 @@ import abc
from datetime import datetime
class LogEntry(object):
class Entry(object):
"""A logbook entry has the bare minimum of these fields."""
def __init__(self, name, metadata=None):
self.created_on = datetime.utcnow()
self.name = name

View File

@@ -1,49 +0,0 @@
# -*- coding: utf-8 -*-
# vim: tabstop=4 shiftwidth=4 softtabstop=4
# Copyright (C) 2012 Yahoo! Inc. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
import abc
class Promise(object):
"""This is an abstraction of a promise to perform some type of job which
can be returned to a user/function... for later lookup on the progress of
the underlying job."""
__metaclass__ = abc.ABCMeta
def __init__(self, job):
self._job = job
@property
def tracking_id(self):
return "p-%s" % (self._job.tracking_id)
def await(self, timeout=None):
"""Attempts to wait until the job fails or finishess."""
raise NotImplementedError()
@abc.abstractproperty
def state(self):
"""Returns the state of the underlying job."""
raise NotImplementedError()
@abc.abstractproperty
def owner(self):
"""Returns the owner of the job, or None if no owner
has been assigned."""
raise NotImplementedError()