Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(584)

Unified Diff: net/tools/testserver/testserver.py

Issue 5196001: Made testserver communicate to parent process with JSON (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fixed whitespace Created 10 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: net/tools/testserver/testserver.py
diff --git a/net/tools/testserver/testserver.py b/net/tools/testserver/testserver.py
index 2a13c2bf6e0cf98c7a3a9bd6b2d3acff90d74449..71badac00c8d2bdc1bd3c4ca345f7d5432920488 100755
--- a/net/tools/testserver/testserver.py
+++ b/net/tools/testserver/testserver.py
@@ -20,6 +20,8 @@ import optparse
import os
import re
import shutil
+# Needed for 2.4 compatibility.
+import simplejson as json
cbentzel 2010/11/17 22:32:50 Just import simplejson - simple enough to search-a
akalin 2010/11/17 23:21:35 It turns out that we run under both 2.4 and 2.6, a
import SocketServer
import sys
import struct
@@ -1302,15 +1304,22 @@ def main(options, args):
# Notify the parent that we've started. (BaseServer subclasses
# bind their sockets on construction.)
if options.startup_pipe is not None:
+ server_data = {
+ 'port': listen_port
+ }
+ server_data_json = json.dumps(server_data)
+ print 'sending server_data: %s' % server_data_json
+ server_data_len = len(server_data_json)
if sys.platform == 'win32':
fd = msvcrt.open_osfhandle(options.startup_pipe, 0)
else:
fd = options.startup_pipe
startup_pipe = os.fdopen(fd, "w")
- # Write the listening port as a 2 byte value. This is _not_ using
- # network byte ordering since the other end of the pipe is on the same
- # machine.
- startup_pipe.write(struct.pack('@H', listen_port))
+ # First write the data length as an unsigned 4-byte value. This
+ # is _not_ using network byte ordering since the other end of the
+ # pipe is on the same machine.
+ startup_pipe.write(struct.pack('=L', server_data_len))
+ startup_pipe.write(server_data_json)
startup_pipe.close()
try:
« net/tools/testserver/run_testserver.cc ('K') | « net/tools/testserver/run_testserver.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698