Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/sugar/network.py
diff options
context:
space:
mode:
authorDan Williams <dcbw@redhat.com>2007-07-18 02:30:23 (GMT)
committer Dan Williams <dcbw@redhat.com>2007-07-18 02:30:23 (GMT)
commit83a49dcd4e150fc8cdb26c92a6b1c353d00f13aa (patch)
treeeb85ec3c1bf99b06567f4efbafce1abb3b6825d0 /sugar/network.py
parent6a6c5fb805abf59cab555afac0846d6c8961ff9a (diff)
Don't close GlibTCPServer sockets prematurely
Diffstat (limited to 'sugar/network.py')
-rw-r--r--sugar/network.py23
1 files changed, 21 insertions, 2 deletions
diff --git a/sugar/network.py b/sugar/network.py
index 4792777..5579aa9 100644
--- a/sugar/network.py
+++ b/sugar/network.py
@@ -69,6 +69,11 @@ class GlibTCPServer(SocketServer.TCPServer):
self.handle_request()
return True
+ def close_request(self, request):
+ """Called to clean up an individual request."""
+ # let the request be closed by the request handler when its done
+ pass
+
class ChunkedGlibHTTPRequestHandler(SimpleHTTPServer.SimpleHTTPRequestHandler):
"""RequestHandler class that integrates with Glib mainloop. It writes
@@ -112,6 +117,7 @@ class ChunkedGlibHTTPRequestHandler(SimpleHTTPServer.SimpleHTTPRequestHandler):
def _cleanup(self):
if self._file:
self._file.close()
+ self._file = None
if self._srcid > 0:
gobject.source_remove(self._srcid)
self._srcid = 0
@@ -507,12 +513,23 @@ def xmlrpc_test(loop):
error_handler=xmlrpc_error_cb,
user_data=loop)
-def main():
- loop = gobject.MainLoop()
+def start_xmlrpc():
server = GlibXMLRPCServer(("", 8888))
inst = Test()
server.register_instance(inst)
gobject.idle_add(xmlrpc_test, loop)
+
+class TestReqHandler(ChunkedGlibHTTPRequestHandler):
+ def translate_path(self, path):
+ return "/tmp/foo"
+
+def start_http():
+ server = GlibTCPServer(("", 8890), TestReqHandler)
+
+def main():
+ loop = gobject.MainLoop()
+# start_xmlrpc()
+ start_http()
try:
loop.run()
except KeyboardInterrupt:
@@ -521,3 +538,5 @@ def main():
if __name__ == "__main__":
main()
+
+