मैं मल्टीप्रोसेसिंग को उपclass करना चाहता हूं। कतार के हिस्सों को पकड़ने के लिए प्रक्रियाओं को कार्यान्वित करने के लिए क्यूयू। एकमात्र समस्या यह है कि, मुझे एक अजीब टाइपरर मिल रहा है?मल्टीप्रोसेसिंग क्यूई सबक्लास समस्या
#!/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)]
इस परीक्षण (मैं इस बाहर विभाजित ताकि मैं और कुछ में खींच नहीं किया गया था)
| => ./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
संपादित करें/अद्यतन:
द्वारा लौटाई गई वस्तु का कतार कैसे शुरू किया जा रहा है? – eugecm
मैं नहीं हूं। आप जो देखते हैं वह संपूर्ण परीक्षण है। मैं वास्तव में किसी भी तरह से कॉल या इसका उपयोग नहीं कर रहा हूं। – SkyLeach
मुझे लगता है कि यह multiprocessing के तरीके से कुछ करने के लिए किया गया है। Queue स्थानीय/साझा संसाधनों को संभालती है? टाइपडिफ के रूप में जेआईटी लोडिंग के दौरान क्लास विनिर्देश को कॉल करना मतलब है कि कोर में कुछ उलझ रहा है AFAICT – SkyLeach