This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

python-2.4.3-1 problem with urllib2


The attached python script works fine under python-2.4.1-1.  Under
python-2.4.3-1, I get this output:

Using urllib.urlopen
......................................................................................................................................................
Using urllib2.urlopen
.............................................................................................Traceback
(most recent call last):
 File "test-urllib.py", line 42, in ?
   doRequest2("http://localhost:8010";)
 File "test-urllib.py", line 16, in doRequest2
   f = urllib2.urlopen(url)
 File "/usr/lib/python2.4/urllib2.py", line 130, in urlopen
   return _opener.open(url, data)
 File "/usr/lib/python2.4/urllib2.py", line 358, in open
   response = self._open(req, data)
 File "/usr/lib/python2.4/urllib2.py", line 376, in _open
   '_open', req)
 File "/usr/lib/python2.4/urllib2.py", line 337, in _call_chain
   result = func(*args)
 File "/usr/lib/python2.4/urllib2.py", line 1021, in http_open
   return self.do_open(httplib.HTTPConnection, req)
 File "/usr/lib/python2.4/urllib2.py", line 996, in do_open
   raise URLError(err)
urllib2.URLError: <urlopen error unable to select on socket>

This happens after a consistent number of requests on my machine.

Cheers,
Chris
#!/usr/bin/python
import urllib2, urllib, BaseHTTPServer, os, sys, signal
class MyHandler(BaseHTTPServer.BaseHTTPRequestHandler):
    def do_GET(self):
        data = "Hello world"
        self.wfile.write("HTTP/1.0 200 OK\nContent-Length: %s\n\n%s" % (
            len(data), data))
        self.wfile.close()

def doRequest(url):
    f = urllib.urlopen(url)
    data = f.read()
    return data
    
def doRequest2(url):
    f = urllib2.urlopen(url)
    data = f.read()
    return data

if __name__ == "__main__":
    n = 150
    pid = os.fork()
    if pid == 0:
	# Run the server
	s = BaseHTTPServer.HTTPServer(("", 8010), MyHandler)
	try:
	    s.serve_forever()
	except KeyboardInterrupt:
	    sys.exit(0)
    else:
	try:
	    print "Using urllib.urlopen"
	    for i in range(n):
		sys.stdout.write(".")
		sys.stdout.flush()
		doRequest("http://localhost:8010";)
	    print
	    print "Using urllib2.urlopen"
	    for i in range(n):
		sys.stdout.write(".")
		sys.stdout.flush()
		doRequest2("http://localhost:8010";)
	finally:
	    os.kill(pid, signal.SIGINT)
--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]