[pypy-svn] r35560 - in pypy/dist/pypy/tool/build: . bin test

guido at codespeak.net guido at codespeak.net
Mon Dec 11 11:04:11 CET 2006


Author: guido
Date: Mon Dec 11 11:04:10 2006
New Revision: 35560

Modified:
   pypy/dist/pypy/tool/build/bin/client
   pypy/dist/pypy/tool/build/client.py
   pypy/dist/pypy/tool/build/test/test_client.py
Log:
Re-added ChannelWrapper to take care of building and sending the zip in chunks
rather than building it fully in memory and sending it over as a whole, removed
some debug prints (or log writes actually), whitespace.


Modified: pypy/dist/pypy/tool/build/bin/client
==============================================================================
--- pypy/dist/pypy/tool/build/bin/client	(original)
+++ pypy/dist/pypy/tool/build/bin/client	Mon Dec 11 11:04:10 2006
@@ -1,7 +1,5 @@
 #!/usr/bin/python
 
-BUFSIZE = 1024
-
 import path
 import sys
 import random
@@ -26,8 +24,6 @@
                path=buildconfig.path,
                port=buildconfig.port)
 
-
-
 print channel.receive() # welcome message
 try:
     try:

Modified: pypy/dist/pypy/tool/build/client.py
==============================================================================
--- pypy/dist/pypy/tool/build/client.py	(original)
+++ pypy/dist/pypy/tool/build/client.py	Mon Dec 11 11:04:10 2006
@@ -27,14 +27,9 @@
         thread.start_new_thread(self.wait_until_done, (info,))
 
     def wait_until_done(self, info):
-        efp = open('/tmp/foo', 'w')
-        efp.write(repr(info) + '\n')
         buildpath = self.server.get_new_buildpath(info)
-        efp.flush()
         
         if not self.testing:
-            efp.write('2\n')
-            efp.flush()
             fp = buildpath.zipfile.open('w')
             try:
                 while True:
@@ -49,13 +44,8 @@
             finally:
                 fp.close()
         
-        efp.write('3\n')
-        efp.flush()
         self.server.compilation_done(info, buildpath)
         self.busy_on = None
-        efp.write(repr(info))
-        efp.flush()
-        efp.close()
 
 initcode = """
     import sys
@@ -89,11 +79,34 @@
     channel = conference.remote_exec(initcode % (path, sysinfo, testing))
     return channel
 
+class ChannelWrapper(object):
+    """ wrapper around a channel
+
+        implements (a small part of) the file interface, sends the data
+        over the wire in chunks, ending with a None
+    """
+    def __init__(self, channel):
+        self.channel = channel
+        self.loc = 0
+
+    def write(self, data):
+        self.loc += len(data)
+        self.channel.send(data)
+
+    def close(self):
+        self.channel.send(None)
+
+    def tell(self):
+        return self.loc
+
+    def flush(self):
+        pass
+
 def zip_result(res_dir, channel):
-    #    channelwrapper = ChannelWrapper(channel)
-    buf = StringIO()
-    zip = ZipFile(buf, 'w')
-    zip.writestr('pypy-c', open('pypy-c').read())
+    channelwrapper = ChannelWrapper(channel)
+    zip = ZipFile(channelwrapper, 'w')
+    # might not be C pypy...
+    # zip.writestr('pypy-c', res_dir.join('testing_1/testing_1').read())
     for fpath in res_dir.visit():
         try:
             zip.writestr(fpath.relto(res_dir), fpath.read())
@@ -101,6 +114,5 @@
             print exc
             continue
     zip.close()
-    channel.send(buf.getvalue())
     channel.send(None)
    

Modified: pypy/dist/pypy/tool/build/test/test_client.py
==============================================================================
--- pypy/dist/pypy/tool/build/test/test_client.py	(original)
+++ pypy/dist/pypy/tool/build/test/test_client.py	Mon Dec 11 11:04:10 2006
@@ -35,7 +35,7 @@
     # available on its own channel, with our FakeChannel it has data rightaway,
     # though (the channel out and in are the same, and we just sent 'info'
     # over the out one)
-    time.sleep(1) 
+    time.sleep(1)
     
     done = svr._done.pop()
     



More information about the Pypy-commit mailing list