Подскажите где ошибка… замучался уже
#!/usr/bin/env python
import re
import pycurl
import StringIO
import threading
class mythread(threading.Thread):
def __init__(self,thread_id, urls):
self.urls = urls
self.thread_id = thread_id
threading.Thread.__init__(self)
def run(self):
urls = self.urls
thread_id = self.thread_id
for x in urls:
url = x.strip()
print url + ' by Thread id=' + str(thread_id)
try:
c = pycurl.Curl()
c.setopt(pycurl.URL, url)
b = StringIO.StringIO()
c.setopt(pycurl.WRITEFUNCTION, b.write)
c.setopt(pycurl.FOLLOWLOCATION, 1)
c.setopt(pycurl.USERAGENT, 'Mozilla/5.0 (X11; U; Linux i686; en-US) AppleWebKit/534.7 (KHTML, like Gecko) Chrome/7.0.517.41 Safari/534.7')
c.setopt(pycurl.MAXREDIRS, 5)
c.setopt(pycurl.PROXYTYPE,pycurl.PROXYTYPE_SOCKS5)
c.setopt(pycurl.PROXY, '127.0.0.1:9050')
c.setopt(pycurl.TIMEOUT, 15)
c.perform()
content = b.getvalue()
c.close()
b.close()
matches = re.compile(r'(?i)<title>(.*?)<\/title>'). findall(content)
title = matches[0].strip()
print url + ' - ' + title
except:
pass
threads_count = 50
f = open('urls.txt', 'r')
ff = f.readlines()
f.close()
loc = 0
fsize = len(ff)/threads_count
arr = []
arr2 = []
for x in ff:
ww = x.strip()
if len(arr2) == fsize:
arr.append(arr2)
arr2 = []
loc = loc + 1
else:
arr2.append(ww)
for x in range(threads_count):
mythread(x, arr[x]).start()
*** longjmp causes uninitialized stack frame ***: python terminated
======= Backtrace: =========
/lib/libc.so.6(__fortify_fail+0x50)[0xb7545980]
/lib/libc.so.6(+0xe58ea)[0xb75458ea]
/usr/lib/libcurl-gnutls.so.4(+0x9d08)[0xb7068d08]
[0xb77c8400]
python[0x810b61c]
python(PyEval_EvalFrameEx+0x4153)[0x80ddd23]
python(PyEval_EvalCodeEx+0x852)[0x80dfbb2]
python(PyEval_EvalFrameEx+0x4575)[0x80de145]
python(PyEval_EvalCodeEx+0x852)[0x80dfbb2]
python(PyEval_EvalFrameEx+0x4575)[0x80de145]
python(PyEval_EvalCodeEx+0x852)[0x80dfbb2]
python[0x8168e3c]
python(PyObject_Call+0x4a)[0x805fd6a]
python[0x8067d5c]
python[0x8061e2a]
python(PyObject_CallMethod+0x64)[0x80651f4]
python(Py_Finalize+0x55)[0x80fd0e5]
python(Py_Main+0x4a6)[0x805b086]
python(main+0x1b)[0x805a8ab]
/lib/libc.so.6(__libc_start_main+0xe7)[0xb7476ce7]
python[0x805a7f1]
======= Memory map: ========
08048000-08225000 r-xp 00000000 08:05 5254091 /usr/bin/python2.6
08225000-08226000 r--p 001dd000 08:05 5254091 /usr/bin/python2.6
08226000-08275000 rw-p 001de000 08:05 5254091 /usr/bin/python2.6
08275000-0827e000 rw-p 00000000 00:00 0
092fd000-0ea05000 rw-p 00000000 00:00 0 [heap]
9dede000-9dedf000 ---p 00000000 00:00 0
9dedf000-9e6df000 rw-p 00000000 00:00 0
9e6df000-9e6e0000 ---p 00000000 00:00 0
9e6e0000-9eee0000 rw-p 00000000 00:00 0
9eee0000-9eee1000 ---p 00000000 00:00 0
9eee1000-9f6e1000 rw-p 00000000 00:00 0
9f6e1000-9f6e2000 ---p 00000000 00:00 0
9f6e2000-9fee2000 rw-p 00000000 00:00 0
9fee2000-9fee3000 ---p 00000000 00:00 0
9fee3000-a06e3000 rw-p 00000000 00:00 0
a06e3000-a06e4000 ---p 00000000 00:00 0
a06e4000-a0ee4000 rw-p 00000000 00:00 0
a0ee4000-a0ee5000 ---p 00000000 00:00 0
a0ee5000-a16e5000 rw-p 00000000 00:00 0
a16e5000-a16e6000 ---p 00000000 00:00 0
a16e6000-a1ee6000 rw-p 00000000 00:00 0
a1ee6000-a1ee7000 ---p 00000000 00:00 0
a1ee7000-a26e7000 rw-p 00000000 00:00 0
a26e7000-a26e8000 ---p 00000000 00:00 0
a26e8000-a2ee8000 rw-p 00000000 00:00 0
a2ee8000-a2ee9000 ---p 00000000 00:00 0
a2ee9000-a36e9000 rw-p 00000000 00:00 0
a36e9000-a36ea000 ---p 00000000 00:00 0
a36ea000-a3eea000 rw-p 00000000 00:00 0
a3eea000-a3eeb000 ---p 00000000 00:00 0
a3eeb000-a46eb000 rw-p 00000000 00:00 0
a46eb000-a46ec000 ---p 00000000 00:00 0
a46ec000-a4eec000 rw-p 00000000 00:00 0
a4eec000-a4eed000 ---p 00000000 00:00 0
a4eed000-a56ed000 rw-p 00000000 00:00 0
a56ed000-a56ee000 ---p 00000000 00:00 0
a56ee000-a5eee000 rw-p 00000000 00:00 0
a5eee000-a5eef000 ---p 00000000 00:00 0
a5eef000-a66ef000 rw-p 00000000 00:00 0
a66ef000-a66f0000 ---p 00000000 00:00 0
a66f0000-a6ef0000 rw-p 00000000 00:00 0
a6ef0000-a6ef1000 ---p 00000000 00:00 0
a6ef1000-a76f1000 rw-p 00000000 00:00 0
a76f1000-a76f2000 ---p 00000000 00:00 0
a76f2000-a7ef2000 rw-p 00000000 00:00 0
a7ef2000-a7ef3000 ---p 00000000 00:00 0
a7ef3000-a86f3000 rw-p 00000000 00:00 0
a86f3000-a86f4000 ---p 00000000 00:00 0
a86f4000-a8ef4000 rw-p 00000000 00:00 0
a8ef4000-a8ef5000 ---p 00000000 00:00 0
a8ef5000-a96f5000 rw-p 00000000 00:00 0
a96f5000-a96f6000 ---p 00000000 00:00 0
a96f6000-a9ef6000 rw-p 00000000 00:00 0
a9ef6000-a9ef7000 ---p 00000000 00:00 0
a9ef7000-aa6f7000 rw-p 00000000 00:00 0
aa6f7000-aa6f8000 ---p 00000000 00:00 0
aa6f8000-aaef8000 rw-p 00000000 00:00 0
aaef8000-aaef9000 ---p 00000000 00:00 0
aaef9000-ab6f9000 rw-p 00000000 00:00 0
ab6f9000-ab6fa000 ---p 00000000 00:00 0
ab6fa000-abefa000 rw-p 00000000 00:00 0
abefa000-abefb000 ---p 00000000 00:00 0
abefb000-ac6fb000 rw-p 00000000 00:00 0
ac6fb000-ac6fc000 ---p 00000000 00:00 0
ac6fc000-acefc000 rw-p 00000000 00:00 0
acefc000-acefd000 ---p 00000000 00:00 0
acefd000-ad6fd000 rw-p 00000000 00:00 0
ad6fd000-ad6fe000 ---p 00000000 00:00 0
ad6fe000-adefe000 rw-p 00000000 00:00 0
adefe000-adeff000 ---p 00000000 00:00 0
adeff000-ae6ff000 rw-p 00000000 00:00 0
ae6ff000-ae700000 ---p 00000000 00:00 0
ae700000-aef00000 rw-p 00000000 00:00 0
aef00000-aefc6000 rw-p 00000000 00:00 0
aefc6000-af000000 ---p 00000000 00:00 0
af0f4000-af0f5000 ---p 00000000 00:00 0
af0f5000-af8f5000 rw-p 00000000 00:00 0
af8f5000-af8f6000 ---p 00000000 00:00 0
af8f6000-b00f6000 rw-p 00000000 00:00 0
b00f6000-b00f7000 ---p 00000000 00:00 0
b00f7000-b08f7000 rw-p 00000000 00:00 0
b08f7000-b08f8000 ---p 00000000 00:00 0
b08f8000-b10f8000 rw-p 00000000 00:00 0
b10f8000-b10f9000 ---p 00000000 00:00 0
b10f9000-b18f9000 rw-p 00000000 00:00 0
b18f9000-b18fa000 ---p 00000000 00:00 0
b18fa000-b20fa000 rw-p 00000000 00:00 0
b20fa000-b20fb000 ---p 00000000 00:00 0
b20fb000-b28fb000 rw-p 00000000 00:00 0
b28fb000-b28fc000 ---p 00000000 00:00 0
b28fc000-b30fc000 rw-p 00000000 00:00 0
b30fc000-b30fd000 ---p 00000000 00:00 0
b30fd000-b38fd000 rw-p 00000000 00:00 0
b38fd000-b38fe000 ---p 00000000 00:00 0
b38fe000-b40fe000 rw-p 00000000 00:00 0
b40fe000-b40ff000 ---p 00000000 00:00 0
b40ff000-b48ff000 rw-p 00000000 00:00 0
b48ff000-b4900000 ---p 00000000 00:00 0
b4900000-b5100000 rw-p 00000000 00:00 0
b5100000-b51de000 rw-p 00000000 00:00 0
b51de000-b5200000 ---p 00000000 00:00 0
b52ec000-b52ed000 ---p 00000000 00:00 0
b52ed000-b5aed000 rw-p 00000000 00:00 0
b5aed000-b5aee000 ---p 00000000 00:00 0
b5aee000-b62ee000 rw-p 00000000 00:00 0
b62ee000-b62ef000 ---p 00000000 00:00 0
b62ef000-b6aef000 rw-p 00000000 00:00 0
b6aef000-b6c8d000 rw-p 00000000 00:00 0
b6d3b000-b6d55000 r-xp 00000000 08:05 10374991 /lib/libgcc_s.so.1
b6d55000-b6d56000 r--p 00019000 08:05 10374991 /lib/libgcc_s.so.1
b6d56000-b6d57000 rw-p 0001a000 08:05 10374991 /lib/libgcc_s.so.1
b6d57000-b6d5b000 r-xp 00000000 08:05 10375355 /lib/libnss_dns-2.12.1.so
b6d5b000-b6d5c000 r--p 00004000 08:05 10375355 /lib/libnss_dns-2.12.1.so
b6d5c000-b6d5d000 rw-p 00005000 08:05 10375355 /lib/libnss_dns-2.12.1.so
b6d6f000-b6d72000 r-xp 00000000 08:05 10374997 /lib/libgpg-error.so.0.4.0
b6d72000-b6d73000 r--p 00002000 08:05 10374997 /lib/libgpg-error.so.0.4.0
b6d73000-b6d74000 rw-p 00003000 08:05 10374997 /lib/libgpg-error.so.0.4.0
b6d74000-b6d83000 r-xp 00000000 08:05 5256844 /usr/lib/libtasn1.so.3.1.9
b6d83000-b6d84000 r--p 0000e000 08:05 5256844 /usr/lib/libtasn1.so.3.1.9
b6d84000-b6d85000 rw-p 0000f000 08:05 5256844 /usr/lib/libtasn1.so.3.1.9
b6d85000-b6d87000 r-xp 00000000 08:05 10375005 /lib/libkeyutils.so.1.3
b6d87000-b6d88000 r--p 00001000 08:05 10375005 /lib/libkeyutils.so.1.3
b6d88000-b6d89000 rw-p 00002000 08:05 10375005 /lib/libkeyutils.so.1.3
b6d89000-b6d8f000 r-xp 00000000 08:05 5256565 /usr/lib/libkrb5support.so.0.1
b6d8f000-b6d90000 r--p 00005000 08:05 5256565 /usr/lib/libkrb5support.so.0.1
b6d90000-b6d91000 rw-p 00006000 08:05 5256565 /usr/lib/libkrb5support.so.0.1
b6d91000-b6d93000 r-xp 00000000 08:05 10374964 /lib/libcom_err.so.2.1
b6d93000-b6d94000 r--p 00001000 08:05 10374964 /lib/libcom_err.so.2.1
b6d94000-b6d95000 rw-p 00002000 08:05 10374964 /lib/libcom_err.so.2.1
b6d95000-b6db6000 r-xp 00000000 08:05 5256559 /usr/lib/libk5crypto.so.3.1
b6db6000-b6db7000 ---p 00021000 08:05 5256559 /usr/lib/libk5crypto.so.3.1
b6db7000-b6db8000 r--p 00021000 08:05 5256559 /usr/lib/libk5crypto.so.3.1
b6db8000-b6db9000 rw-p 00022000 08:05 5256559 /usr/lib/libk5crypto.so.3.1
b6db9000-b6e61000 r-xp 00000000 08:05 5256563 /usr/lib/libkrb5.so.3.3Аварийный останов
Python: 2.6