Redesign cleanupSites() and all the related stuff and rename it to periodic maintenance.
This commit is contained in:
parent
511a90a5c5
commit
8fd88c50f9
6 changed files with 175 additions and 81 deletions
34
src/util/CircularIterator.py
Normal file
34
src/util/CircularIterator.py
Normal file
|
@ -0,0 +1,34 @@
|
|||
import random
|
||||
|
||||
class CircularIterator:
|
||||
def __init__(self):
|
||||
self.successive_count = 0
|
||||
self.last_size = 0
|
||||
self.index = -1
|
||||
|
||||
def next(self, items):
|
||||
self.last_size = len(items)
|
||||
|
||||
if self.last_size == 0:
|
||||
return None
|
||||
|
||||
if self.index < 0:
|
||||
self.index = random.randint(0, self.last_size)
|
||||
else:
|
||||
self.index += 1
|
||||
|
||||
self.index = self.index % self.last_size
|
||||
|
||||
self.successive_count += 1
|
||||
|
||||
return items[self.index]
|
||||
|
||||
def resetSuccessiveCount(self):
|
||||
self.successive_count = 0
|
||||
|
||||
def getSuccessiveCount(self):
|
||||
return self.successive_count
|
||||
|
||||
def isWrapped(self):
|
||||
return self.successive_count >= self.last_size
|
||||
|
|
@ -1,4 +1,5 @@
|
|||
from .Cached import Cached
|
||||
from .CircularIterator import CircularIterator
|
||||
from .Event import Event
|
||||
from .Noparallel import Noparallel
|
||||
from .Pooled import Pooled
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue