キューのチャンクを取得するプロセスを実装するために、マルチプロセッシングをサブクラス化したい。唯一の問題は、奇妙なTypeErrorが発生していることです。マルチプロセッシングキューのサブクラスの問題
この(私は他の何かに引っ張っていなかったように私はこれを分割)| => ./tests/wtf_queue.py
Traceback (most recent call last):
File "./tests/wtf_queue.py", line 10, in <module>
class BufferQueue(Queue):
TypeError: method expected 2 arguments, got 3
編集/更新テスト
#!/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
return [self.popleft() for i in range(lim)]
:
どのようにキューを初期化していますか? – eugecm
私はそうではありません。あなたが見ているのはテスト全体です。私は実際に何かを呼び出したり使用したりしていません。 – SkyLeach
私はこれがマルチプロセッシングの方法と関係していると思っています.Queueはローカル/共有リソースを処理しますか? JITのロード中にクラス仕様をTypeDefとして呼び出すと、コアの中の何かが混乱しているということになります。AFAICT – SkyLeach