美文网首页
pyspider源码-schuduler.py之itertool

pyspider源码-schuduler.py之itertool

作者: comboo | 来源:发表于2017-04-12 10:11 被阅读46次

    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
    

    相关文章

      网友评论

          本文标题:pyspider源码-schuduler.py之itertool

          本文链接:https://www.haomeiwen.com/subject/hynpattx.html