[Inteproxy-commits] r212 - in trunk: . inteproxy
scm-commit@wald.intevation.org
scm-commit at wald.intevation.org
Tue Sep 15 21:54:02 CEST 2009
Author: bh
Date: 2009-09-15 21:54:00 +0200 (Tue, 15 Sep 2009)
New Revision: 212
Modified:
trunk/ChangeLog
trunk/inteproxy/httpserver.py
Log:
* inteproxy/httpserver.py: Adapt to changes in Python 2.6. 2.6
introduced its own method of shutting down the socket server which
interferes with InteProxy's approach and leads to dead locks. The
new code works with Python 2.6 and older versions.
Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog 2009-09-11 20:43:06 UTC (rev 211)
+++ trunk/ChangeLog 2009-09-15 19:54:00 UTC (rev 212)
@@ -1,3 +1,10 @@
+2009-09-15 Bernhard Herzog <bh at intevation.de>
+
+ * inteproxy/httpserver.py: Adapt to changes in Python 2.6. 2.6
+ introduced its own method of shutting down the socket server which
+ interferes with InteProxy's approach and leads to dead locks. The
+ new code works with Python 2.6 and older versions.
+
2009-09-11 Bernhard Herzog <bh at intevation.de>
* inteproxy/transcoder.py (IdentityTranscoder.__init__): Fix typo
Modified: trunk/inteproxy/httpserver.py
===================================================================
--- trunk/inteproxy/httpserver.py 2009-09-11 20:43:06 UTC (rev 211)
+++ trunk/inteproxy/httpserver.py 2009-09-15 19:54:00 UTC (rev 212)
@@ -1,4 +1,4 @@
-# Copyright (C) 2007 by Intevation GmbH
+# Copyright (C) 2007, 2009 by Intevation GmbH
# Authors:
# Bernhard Herzog <bh at intevation.de>
#
@@ -28,7 +28,7 @@
while not self.do_shutdown:
self.handle_request()
- def server_close(self):
+ def shutdown(self):
"""Shutdown the server.
Usually this is called from a thread while another thread
@@ -38,7 +38,6 @@
do something to unblock the other thread, such as creating a TCP
connection to the server.
"""
- BaseHTTPServer.HTTPServer.server_close(self)
self.do_shutdown = True
@@ -67,14 +66,15 @@
if self.server_thread is None:
return
- self.server.server_close()
+ self.server.shutdown()
# The server thread might be blocked while listening on the
# socket. Unblock it by connecting to the port.
+ s = None
try:
s = socket.socket()
s.connect(("localhost", self.server_port))
- s.close()
+ s.shutdown(socket.SHUT_WR)
except socket.error, exc:
# The server may have shut down already when we try to
# connect, so we ignore connection failures.
@@ -85,3 +85,8 @@
self.server_thread.join()
self.server_thread = None
+
+ self.server.server_close()
+
+ if s is not None:
+ s.close()
More information about the Inteproxy-commits
mailing list