예제 #1
0
class ProcessGroupDict(DataDict):
    item_cls = ProcessGroup
    key = "id"
    
    def __init__(self):
        self.id_gen = IncrID()
 
    def q_add (self, specs, callback=None, cargs={}):
        for spec in specs:
            if spec.get("id", "*") != "*":
                raise DataCreationError("cannot specify an id")
            spec['id'] = self.id_gen.next()
        return DataDict.q_add(self, specs)
예제 #2
0
파일: cpm.py 프로젝트: benmcclelland/cobalt
class JobDict (DataDict):
    
    item_cls = Job
    key = "id"

    def __init__(self):
        self.id_gen = IncrID()
        
    def q_add (self, specs, callback=None, cargs={}):
        for spec in specs:
            if "id" not in spec or spec['id'] == "*":
                spec['id'] = self.id_gen.next()
        return DataDict.q_add(self, specs)
예제 #3
0
class ProcessGroupDict(DataDict):
    item_cls = ProcessGroup
    key = "id"

    def __init__(self):
        self.id_gen = IncrID()

    def q_add(self, specs, callback=None, cargs={}):
        for spec in specs:
            if spec.get("id", "*") != "*":
                raise DataCreationError("cannot specify an id")
            spec['id'] = self.id_gen.next()
        return DataDict.q_add(self, specs)
예제 #4
0
class ProcessGroupDict(DataDict):
    """A container for holding process groups, keyed by id"""

    item_cls = ProcessGroup
    key = "id"
    
    def __init__(self):
        DataDict.__init__(self)
        self.id_gen = IncrID()

    def q_add(self, specs, callback=None, cargs={}):
        """Add a process group to the container"""
        for spec in specs:
            if spec.get("id", "*") != "*":
                raise DataCreationError("cannot specify an id")
            spec["id"] = self.id_gen.next()
        return DataDict.q_add(self, specs, callback, cargs)
예제 #5
0
 def test_next(self, max=100):
     generator = IncrID()
     for count in itertools.count(1):
         assert generator.next() == count
         if count >= max:
             break
예제 #6
0
 def test_next (self, max=100):
     generator = IncrID()
     for count in itertools.count(1):
         assert generator.next() == count
         if count >= max:
             break