Index: net/tools/testserver/testserver.py |
diff --git a/net/tools/testserver/testserver.py b/net/tools/testserver/testserver.py |
index 2a13c2bf6e0cf98c7a3a9bd6b2d3acff90d74449..162609bbf5c995880371de906f5158198b1aba45 100755 |
--- a/net/tools/testserver/testserver.py |
+++ b/net/tools/testserver/testserver.py |
@@ -27,6 +27,11 @@ import time |
import urlparse |
import warnings |
+if sys.version_info < (2, 6): |
Paweł Hajdan Jr.
2010/11/18 10:35:12
Hmmm. Can we use the same version of the library,
akalin
2010/11/18 22:38:34
I get warnings if I try to use simplejson only. I
|
+ import simplejson as json |
+else: |
+ import json |
+ |
# Ignore deprecation warnings, they make our output more cluttered. |
warnings.filterwarnings("ignore", category=DeprecationWarning) |
@@ -1302,15 +1307,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 |
Paweł Hajdan Jr.
2010/11/18 10:35:12
nit: Only for debugging?
|
+ 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: |