示例#1
0
class Job(flavors.RemoteCopy, flavors.Copyable):
    ''' Job definition '''

    def __init__(self, command, job_id, status = None):
        self.command = command
        self.job_id = job_id
        if status == None:
            self.status = 'ready'
        else:
            self.status = status

class ReceiverJob(flavors.RemoteCopy, flavors.Copyable):
    pass

flavors.setUnjellyableForClass(Job, ReceiverJob)
flavors.setUnjellyableForClass(ReceiverJob, Job)

class NodeInfo(flavors.RemoteCopy, flavors.Copyable):
    ''' Node information '''

    def __init__(self, instance_type = None, node_id = None):
        self.instance_type = instance_type
        self.node_id = node_id
        self.connected = True
        self.cur_jobs = 0

class ReceiverNodeInfo(flavors.RemoteCopy, flavors.Copyable):
    pass

flavors.setUnjellyableForClass(NodeInfo, ReceiverNodeInfo)
示例#2
0
文件: pb.py 项目: jobajuba/Tsunami
                return cmp(self.luid, other.luid)
        return cmp(self.broker, other)

    def __hash__(self):
        """Hash me.
        """
        return self.luid

    def __del__(self):
        """Do distributed reference counting on finalization.
        """
        if self.doRefCount:
            self.broker.sendDecRef(self.luid)


setUnjellyableForClass("remote", RemoteReference)


class Local:
    """(internal) A reference to a local object.
    """
    def __init__(self, object, perspective=None):
        """Initialize.
        """
        self.object = object
        self.perspective = perspective
        self.refcount = 1

    def __repr__(self):
        return "<pb.Local %r ref:%s>" % (self.object, self.refcount)
示例#3
0
                return cmp(self.luid, other.luid)
        return cmp(self.broker, other)

    def __hash__(self):
        """Hash me.
        """
        return self.luid

    def __del__(self):
        """Do distributed reference counting on finalization.
        """
        if self.doRefCount:
            self.broker.sendDecRef(self.luid)


setUnjellyableForClass("remote", RemoteReference)


class Local:
    """(internal) A reference to a local object.
    """

    def __init__(self, object, perspective=None):
        """Initialize.
        """
        self.object = object
        self.perspective = perspective
        self.refcount = 1

    def __repr__(self):
        return "<pb.Local %r ref:%s>" % (self.object, self.refcount)
示例#4
0
文件: xml.py 项目: Emm/Cerebus
import math
import random

from twisted.spread import flavors

class Filter(flavors.Copyable, flavors.RemoteCopy):
    status = 'created'
    pass

class XmlFilter(Filter):
    def run(self):
        print "xml_filter"
        result = 0
        for i in range(random.randint(1000000, 3000000)):
            angle = math.radians(random.randint(0, 45))
            result += math.tanh(angle)/math.cosh(angle)
        return "%s, result: %.2f" % (self, result)

class XslFilter(Filter):
    def run(self):
        print "xsl_filter"
        result = 0
        for i in range(random.randint(1000000, 3000000)):
            angle = math.radians(random.randint(0, 45))
            result += math.tanh(angle)/math.cosh(angle)
        return "%s, result: %.2f" % (self, result)

flavors.setUnjellyableForClass(XmlFilter, XmlFilter)
flavors.setUnjellyableForClass(XslFilter, XslFilter)
示例#5
0
        for a, b in d.items():
            if isinstance(b, (list, tuple)):
                setattr(
                    self, a,
                    [obj(x, False) if isinstance(x, dict) else x for x in b])
            else:
                setattr(self, a, obj(b, False) if isinstance(b, dict) else b)

    def unobjectify(self):
        if not self.__original__:
            raise TypeError("not root obj node")

        return self.__original__


flavors.setUnjellyableForClass(BasicRequest, RemoteBasicRequest)


class BasicMultiRequest(flavors.Copyable):
    def __init__(self, requests):
        self.requests = requests

    def __iter__(self):
        return iter(self.requests)


class RemoteBasicMultiRequest(flavors.RemoteCopy):
    pass


class BasicResponse(flavors.Copyable):
示例#6
0
def establishObjects():
    flavors.setUnjellyableForClass(LogEntry, RemoteLogEntry)
示例#7
0
文件: service.py 项目: pgk/mamba
            self.__original__ = None
        for a, b in d.items():
            if isinstance(b, (list, tuple)):
               setattr(self, a, [obj(x, False) if isinstance(x, dict) else x for x in b])
            else:
               setattr(self, a, obj(b, False) if isinstance(b, dict) else b)

    def unobjectify(self):
        if not self.__original__:
            raise TypeError("not root obj node")

        return self.__original__



flavors.setUnjellyableForClass(BasicRequest, RemoteBasicRequest)


class BasicMultiRequest(flavors.Copyable):

    def __init__(self, requests):
        self.requests = requests

    def __iter__(self):
        return iter(self.requests)


class RemoteBasicMultiRequest(flavors.RemoteCopy):
    pass