Problem with urllib2
#1
Hello,

The problem is that it seems like when I'm doing multiple urllib2.open i get errors.
I've tried lowering the defaultsockettimeout but it didn't help.

If I run this code:
Code:
import urllib2, traceback

counter = 1
opener = urllib2.build_opener()

while counter <= 100:
    print counter
    try:
        opened = opener.open("http://www.sunet.se/index.html")
        opened.close()
    except:
        traceback.print_exc()
        break
    counter += 1
I get this type of error:
Code:
......
10:42:32 M:1549406208    INFO: 42
10:42:32 M:1549406208    INFO:
10:42:33 M:1549352960    INFO: 43
10:42:33 M:1549352960    INFO:
10:42:33 M:1549307904    INFO: 44
10:42:33 M:1549307904    INFO:
10:42:33 M:1549557760    INFO: 45
10:42:33 M:1549557760    INFO:
10:42:33 M:1549484032    INFO: 46
10:42:33 M:1549484032    INFO:
10:42:33 M:1549484032   ERROR: GetSocketForIndex() invalid index:0
10:42:33 M:1549484032   ERROR: GetSocketForIndex() invalid index:0
10:42:33 M:1549484032   ERROR: GetSocketForIndex() invalid index:0
10:42:33 M:1549484032   ERROR: ReleaseSocket() invalid index:0
10:42:33 M:1549484032    INFO: Traceback (most recent call last):
10:42:33 M:1549086720    INFO:   File "q:\scripts\test\default.py", line 10, in ?
10:42:33 M:1549086720    INFO: Stating file q:\scripts\test\default.py
10:42:33 M:1549082624    INFO:     opened = opener.open("http://www.sunet.se/index.html")
10:42:33 M:1549082624    INFO:   File "Q:\system\python\python24.zlib\urllib2.py", line 358, in open
10:42:33 M:1549082624    INFO: Stating file Q:\system\python\python24.zlib\urllib2.py
10:42:33 M:1549082624    INFO: Stating file q:\scripts\test\urllib2.py
10:42:33 M:1549082624    INFO: Stating file Q:\system\python\python24.zlib\urllib2.py
10:42:33 M:1549082624    INFO: Stating file Q:\system\python\DLLs\urllib2.py
10:42:33 M:1549082624    INFO: Stating file Q:\system\python\Lib\urllib2.py
10:42:33 M:1549082624    INFO: Stating file Q:\system\python\spyce\urllib2.py
10:42:33 M:1549082624    INFO:   File "Q:\system\python\python24.zlib\urllib2.py", line 376, in _open
10:42:33 M:1549082624    INFO: Stating file Q:\system\python\python24.zlib\urllib2.py
10:42:33 M:1549082624    INFO: Stating file q:\scripts\test\urllib2.py
10:42:33 M:1549082624    INFO: Stating file Q:\system\python\python24.zlib\urllib2.py
10:42:33 M:1549082624    INFO: Stating file Q:\system\python\DLLs\urllib2.py
10:42:33 M:1549082624    INFO: Stating file Q:\system\python\Lib\urllib2.py
10:42:33 M:1549082624    INFO: Stating file Q:\system\python\spyce\urllib2.py
10:42:33 M:1549082624    INFO:   File "Q:\system\python\python24.zlib\urllib2.py", line 337, in _call_chain
10:42:33 M:1549082624    INFO: Stating file Q:\system\python\python24.zlib\urllib2.py
10:42:33 M:1549082624    INFO: Stating file q:\scripts\test\urllib2.py
10:42:33 M:1549078528    INFO: Stating file Q:\system\python\python24.zlib\urllib2.py
10:42:33 M:1549078528    INFO: Stating file Q:\system\python\DLLs\urllib2.py
10:42:33 M:1549078528    INFO: Stating file Q:\system\python\Lib\urllib2.py
10:42:33 M:1549078528    INFO: Stating file Q:\system\python\spyce\urllib2.py
10:42:33 M:1549078528    INFO:   File "Q:\system\python\python24.zlib\urllib2.py", line 1021, in http_open
10:42:33 M:1549078528    INFO: Stating file Q:\system\python\python24.zlib\urllib2.py
10:42:33 M:1549078528    INFO: Stating file q:\scripts\test\urllib2.py
10:42:33 M:1549078528    INFO: Stating file Q:\system\python\python24.zlib\urllib2.py
10:42:33 M:1549078528    INFO: Stating file Q:\system\python\DLLs\urllib2.py
10:42:33 M:1549078528    INFO: Stating file Q:\system\python\Lib\urllib2.py
10:42:33 M:1549078528    INFO: Stating file Q:\system\python\spyce\urllib2.py
10:42:33 M:1549078528    INFO:   File "Q:\system\python\python24.zlib\urllib2.py", line 996, in do_open
10:42:33 M:1549078528    INFO: Stating file Q:\system\python\python24.zlib\urllib2.py
10:42:33 M:1549078528    INFO: Stating file q:\scripts\test\urllib2.py
10:42:33 M:1549078528    INFO: Stating file Q:\system\python\python24.zlib\urllib2.py
10:42:33 M:1549078528    INFO: Stating file Q:\system\python\DLLs\urllib2.py
10:42:33 M:1549078528    INFO: Stating file Q:\system\python\Lib\urllib2.py
10:42:33 M:1549078528    INFO: Stating file Q:\system\python\spyce\urllib2.py
10:42:33 M:1549078528    INFO: URLError: <urlopen error (10038, 'Socket operation on non-socket')>

Does anyone else have this problem?
Is there anything I'm doing wrong?
Reply

Logout Mark Read Team Forum Stats Members Help
Problem with urllib20