Пример #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
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