fix already-stopped

This commit is contained in:
meejah 2023-12-18 23:27:16 -07:00
parent 194011946c
commit d70fa461da
2 changed files with 10 additions and 8 deletions

View File

@ -63,11 +63,12 @@ class SegmentFetcher(object):
self._running = True
def stop(self):
if self._running:
log.msg("SegmentFetcher(%r).stop" % self._node._si_prefix,
level=log.NOISY, parent=self._lp, umid="LWyqpg")
self._cancel_all_requests()
self._running = False
# help GC ??? XXX
# help GC ???
del self._shares, self._shares_from_server, self._active_share_map
del self._share_observers

View File

@ -533,10 +533,11 @@ class DownloadNode(object):
self._segment_requests = [t for t in self._segment_requests
if t[2] != cancel]
segnums = [segnum for (segnum,d,c,seg_ev,lp) in self._segment_requests]
# self._active_segment might be None in rare circumstances, so make
# sure we tolerate it
if self._active_segment and self._active_segment.segnum not in segnums:
seg, self._active_segment = self._active_segment, None##True # XXX None for real
seg, self._active_segment = self._active_segment, None
seg.stop()
self._start_new_segment()