Ticket #1268: mergeloops.diff

File mergeloops.diff, 1.4 KB (added by warner, at 2011-08-01T04:37:23Z)

patch to merge loops

  • src/allmydata/immutable/downloader/share.py

    diff --git a/src/allmydata/immutable/downloader/share.py b/src/allmydata/immutable/downloader/share.py
    index 95173ae..1918d90 100644
    a b class Share: 
    5252        self._dyhb_rtt = dyhb_rtt
    5353        # self._alive becomes False upon fatal corruption or server error
    5454        self._alive = True
     55        self._loop_scheduled = False
    5556        self._lp = log.msg(format="%(share)s created", share=repr(self),
    5657                           level=log.NOISY, parent=logparent, umid="P7hv2w")
    5758
    class Share: 
    164165                break
    165166        else:
    166167            self._requested_blocks.append( (segnum, set([o])) )
    167         eventually(self.loop)
     168        self.schedule_loop()
    168169        return o
    169170
    170171    def _cancel_block_request(self, o):
    class Share: 
    184185            return self._requested_blocks[0]
    185186        return None, []
    186187
     188    def schedule_loop(self):
     189        if self._loop_scheduled:
     190            return
     191        self._loop_scheduled = True
     192        eventually(self.loop)
     193
    187194    def loop(self):
     195        self._loop_scheduled = False
    188196        if not self._alive:
    189197            return
    190198        try:
    class Share: 
    797805
    798806    def _trigger_loop(self, res):
    799807        if self._alive:
    800             eventually(self.loop)
     808            self.schedule_loop()
    801809        return res
    802810
    803811    def _fail(self, f, level=log.WEIRD):