Вот кусок кода моей программы, где используется модуль Queue:
import Queue
....
ipq=Queue.Queue(0)
resq=Queue.Queue(0)
exit_event_w=Event()
exit_event_d=Event()
class WorkerThread(threading.Thread):
def run(self):
while not exit_event_w.isSet():
try:
ip=ipq.get()
res=check_and_get(ip)
resq.put(ip,res)
ipq.task_done()
except ipq.Empty():
pass
class DataThread(threading.Thread):
def run(self):
while not exit_event_d.isSet():
try:
res_string=''
r=open('./result','a')
for res_element in resq.get():
res_string=res_string+str(res_element)
res_string=res_string+'\n'
r.write(res_string)
r.close
resq.task_done()
except resq.Empty():
pass
....
Exception in thread Thread-30:
Traceback (most recent call last):
File "/usr/lib/python2.6/threading.py", line 525, in __bootstrap_inner
self.run()
File "./threading_snmp_get.py", line 67, in run
except ipq.Empty():
AttributeError: Queue instance has no attribute 'Empty'
Заранее спасибо!