forum.vmspython.org Forum Index forum.vmspython.org
Forum system
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

SimpleHTTPServer.test() fails

 
Post new topic   Reply to topic    forum.vmspython.org Forum Index -> Python for OpenVMS
View previous topic :: View next topic  
Author Message
Colin Brown



Joined: 11 Oct 2012
Posts: 18
Location: Wellington, NZ

PostPosted: Mon Nov 05, 2012 12:15 am    Post subject: SimpleHTTPServer.test() fails Reply with quote

Do other users also get this fault?

$ python -c "import SimpleHTTPServer;SimpleHTTPServer.test()"
TCP/IP Team...entered getaddrinfo_compat43
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/python_root/lib/SimpleHTTPServer.py", line 216, in test
BaseHTTPServer.test(HandlerClass, ServerClass)
File "/python_root/lib/BaseHTTPServer.py", line 595, in test
httpd = ServerClass(server_address, HandlerClass)
File "/python_root/lib/SocketServer.py", line 419, in __init__
self.server_bind()
File "/python_root/lib/BaseHTTPServer.py", line 108, in server_bind
SocketServer.TCPServer.server_bind(self)
File "/python_root/lib/SocketServer.py", line 430, in server_bind
self.socket.bind(self.server_address)
File "/python_root/lib/socket.py", line 224, in meth
return getattr(self._sock,name)(*args)
socket.gaierror: [Errno 2] temporary failure
Back to top
View user's profile Send private message
leogah



Joined: 20 May 2011
Posts: 1

PostPosted: Mon Nov 05, 2012 2:01 pm    Post subject: Reply with quote

Yes, see the thread "Problem with UDP socket"
Back to top
View user's profile Send private message
Colin Brown



Joined: 11 Oct 2012
Posts: 18
Location: Wellington, NZ

PostPosted: Mon Nov 05, 2012 10:04 pm    Post subject: Reply with quote

Thanks, yes it is the same problem and can be worked around again here by changing the empty string with socket.getfqdn() as below (when indented properly):

import BaseHTTPServer, SimpleHTTPServer, socket, sys

def Test(HandlerClass = BaseHTTPServer.BaseHTTPRequestHandler,
ServerClass = BaseHTTPServer.HTTPServer, protocol="HTTP/1.0"):
"""Test the HTTP request handler class.

This runs an HTTP server on port 8000 (or the first command line
argument).

"""

if sys.argv[1:]:
port = int(sys.argv[1])
else:
port = 8000
server_address = (socket.getfqdn(), port)

HandlerClass.protocol_version = protocol
httpd = ServerClass(server_address, HandlerClass)

sa = httpd.socket.getsockname()
print "Serving HTTP on", sa[0], "port", sa[1], "..."
httpd.serve_forever()

# mainline
BaseHTTPServer.test = Test
SimpleHTTPServer.test()
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    forum.vmspython.org Forum Index -> Python for OpenVMS All times are GMT + 2 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group