本文整理匯總了Python中six.advance_iterator方法的典型用法代碼示例。如果您正苦於以下問題:Python six.advance_iterator方法的具體用法?Python six.advance_iterator怎麽用?Python six.advance_iterator使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類six
的用法示例。
在下文中一共展示了six.advance_iterator方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: _iter_cached
# 需要導入模塊: import six [as 別名]
# 或者: from six import advance_iterator [as 別名]
def _iter_cached(self):
i = 0
gen = self._cache_gen
cache = self._cache
acquire = self._cache_lock.acquire
release = self._cache_lock.release
while gen:
if i == len(cache):
acquire()
if self._cache_complete:
break
try:
for j in range(10):
cache.append(advance_iterator(gen))
except StopIteration:
self._cache_gen = gen = None
self._cache_complete = True
break
release()
yield cache[i]
i += 1
while i < self._len:
yield cache[i]
i += 1
示例2: __getitem__
# 需要導入模塊: import six [as 別名]
# 或者: from six import advance_iterator [as 別名]
def __getitem__(self, item):
if self._cache_complete:
return self._cache[item]
elif isinstance(item, slice):
if item.step and item.step < 0:
return list(iter(self))[item]
else:
return list(itertools.islice(self,
item.start or 0,
item.stop or sys.maxsize,
item.step or 1))
elif item >= 0:
gen = iter(self)
try:
for i in range(item+1):
res = advance_iterator(gen)
except StopIteration:
raise IndexError
return res
else:
return list(iter(self))[item]
示例3: dstat_get_jobs
# 需要導入模塊: import six [as 別名]
# 或者: from six import advance_iterator [as 別名]
def dstat_get_jobs(statuses=None,
job_ids=None,
task_ids=None,
labels=None,
create_time_min=None,
create_time_max=None):
"""Build up test parameters and call dstat.dstat_job_producer()."""
statuses = statuses or {'*'}
labels = labels or {}
labels['test-token'] = test_setup.TEST_TOKEN
labels['test-name'] = test_setup.TEST_NAME
labels_set = {job_model.LabelParam(k, v) for (k, v) in labels.items()}
return six.advance_iterator(
dstat.dstat_job_producer(
provider=get_dsub_provider(),
statuses=statuses,
job_ids=job_ids,
task_ids=task_ids,
labels=labels_set,
create_time_min=create_time_min,
create_time_max=create_time_max,
full_output=True))
示例4: __init__
# 需要導入模塊: import six [as 別名]
# 或者: from six import advance_iterator [as 別名]
def __init__(self, chronology):
"""The chronology is a generator that updates the world.
Yield how many seconds of fake time elapse. Think of each yield as a
"sleep". We read the very first value immediately, so that the world can be
initialized in the chronology.
Args:
chronology: a generator that updates the state of the world and then
sleeps via yielding.
"""
self._chronology = chronology
# current fake time
self._now = 0
# time at which to wake up the chronology
self._next = six.advance_iterator(self._chronology)