欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

pyspider源码-schuduler.py之itertools

程序员文章站 2022-05-14 17:16:38
...

import itertools
import json
import logging
import os
import time
from collections import deque

from six import iteritems, itervalues
from six.moves import queue as Queue

from pyspider.libs import counter, utils
from pyspider.libs.base_handler import BaseHandler
from .task_queue import TaskQueue

itertools

for _, project in itertools.chain(top_3_actives, top_2_fails):

itertools.chain(*iterables)
Make an iterator that returns elements from the first iterable until it is exhausted, then proceeds to the next iterable, until all of the iterables are exhausted. Used for treating consecutive sequences as a single sequence. Roughly equivalent to:
做一个迭代器返回元素,先从第一个可迭代对象知道它耗尽,然后处理第二个可迭代对象.被用来将连续的序列作为一个单独序列.大概像这样

def chain(*iterables):
    # chain('ABC', 'DEF') --> A B C D E F
    for it in iterables:
        for element in it:
            yield element