Commit a8c2d608 authored by Alexandre Boeglin's avatar Alexandre Boeglin

Make sure we really got a response from the HTTP server before entering the

TimerServer loop (behaves more like urllib would, but without dealing with a
http_proxy).


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@18235 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 93189352
...@@ -55,15 +55,17 @@ class TimerServer: ...@@ -55,15 +55,17 @@ class TimerServer:
ip = socket.gethostbyname(socket.gethostname()) ip = socket.gethostbyname(socket.gethostname())
# To be very sure, try to connect to the HTTPServer # To be very sure, try to connect to the HTTPServer
# and only start after we are able to connect # and only start after we are able to connect and got a response
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.settimeout(None)
while 1: while 1:
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.settimeout(5)
try: try:
s.connect((ip, port)) s.connect((ip, port))
except (socket.error, socket.timeout): except socket.error:
s.close() time.sleep(5)
continue continue
s.send('GET / HTTP/1.1\r\n\r\n')
s.recv(4096) # blocks until a response is received
break break
s.close() s.close()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment