[Erp5-report] r18235 - /erp5/trunk/products/TimerService/timerserver/TimerServer.py

nobody at svn.erp5.org nobody at svn.erp5.org
Tue Dec 11 15:12:11 CET 2007


Author: alex
Date: Tue Dec 11 15:12:10 2007
New Revision: 18235

URL: http://svn.erp5.org?rev=18235&view=rev
Log:
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).

Modified:
    erp5/trunk/products/TimerService/timerserver/TimerServer.py

Modified: erp5/trunk/products/TimerService/timerserver/TimerServer.py
URL: http://svn.erp5.org/erp5/trunk/products/TimerService/timerserver/TimerServer.py?rev=18235&r1=18234&r2=18235&view=diff
==============================================================================
--- erp5/trunk/products/TimerService/timerserver/TimerServer.py (original)
+++ erp5/trunk/products/TimerService/timerserver/TimerServer.py Tue Dec 11 15:12:10 2007
@@ -55,15 +55,17 @@
         ip = socket.gethostbyname(socket.gethostname())
 
         # 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:
-            s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
-            s.settimeout(5)
             try:
                 s.connect((ip, port))
-            except (socket.error, socket.timeout):
-                s.close()
+            except socket.error:
+                time.sleep(5)
                 continue
+            s.send('GET / HTTP/1.1\r\n\r\n')
+            s.recv(4096) # blocks until a response is received
             break
         s.close()
 




More information about the Erp5-report mailing list