while not myqueue.empty():
mydata = myqueue.get()
>>> import Queue
>>> help(Queue.Queue.get)
Help on method get in module Queue:
get(self, block=True, timeout=None) unbound Queue.Queue method
Remove and return an item from the queue.
If optional args 'block' is true and 'timeout' is None (the default),
block if necessary until an item is available. If 'timeout' is
a positive number, it blocks at most 'timeout' seconds and raises
the Empty exception if no item was available within that time.
Otherwise ('block' is false), return an item if one is immediately
available, else raise the Empty exception ('timeout' is ignored
in that case).
tibsfor работает и с итераторами
А чем тогда цикл for заменить? Он же вроде только с коллекциями работает.
myqueue = []
init_queue(myqueue)
for link in myqueue:
try:
process_link(link)
except Exception:
myqueue.append(link)
for ref in ref_source:
while not process_ref( ref ):
do_wait() # ждем
m=re.findall(re1,r,16)
for topic_id in m:
try:
# open torrent url
torrent_url = 'http://{{tracker}}/forum/dl.php?t=%s' % topic_id
handle = opener.open(torrent_url, data)
# write it to output file
out = open('torrent/[{{tracker}}].t%s.torrent'%topic_id, 'wb')
out.write(handle.read())
out.close()
except Exception,e:
print e
open('%s.html'%topic_id,'wb+').write(str(e))
else:
print u"%s Торрент успешно сохранен"%topic_id
time.sleep(5)
tibsути какое палево
torrent_url = 'http://pornolab.net/forum/dl.php?t=%s' % topic_id
tibsm - итератор по группам, найденным регуляркой
После re.findall переменная m - это что? список?
tibsСначала создай Queue и в цикле тупо засунь туда урлы. Потом делай try:except на открытие каждого урла и в случае ошибки запихивай этот урл обратно в очередь. Код написать не успел, но общий принцип должен быть понятен.
И как мне код поправить?