小编Sky*_*ach的帖子

多处理队列子类问题

我想将multiprocessing.Queue子类化,以实现抓取队列块的进程.唯一的问题是,我得到一个奇怪的TypeError?

#!/usr/bin/env python

#whaaaaa!?

from multiprocessing import Queue

class BufferQueue(Queue):
    '''A thread/process safe queue for append/popleft operations with the import
    buffer.'''

    def __init__(self, **kwargs):
        super(BufferQueue,self).__init__(**kwargs)

    def consume(self, lim):
        '''Consume up to but no more than lim elements and return them in a new
        list, cleaning up the buffer.

        @params
        lim -- the maximum (limit) to consume from the list.  If less items
        exist in the list then that's fine too.
        '''
        lim = len(queue) if len(queue) < lim else lim …
Run Code Online (Sandbox Code Playgroud)

multiprocessing python-3.x

9
推荐指数
1
解决办法
1651
查看次数

标签 统计

multiprocessing ×1

python-3.x ×1