Rev 4: Use a StringIO for the request, which means everything is done in ram. in http://bzr.arbash-meinel.com/plugins/dummy_request

John Arbash Meinel john at arbash-meinel.com
Sat Dec 12 21:09:05 GMT 2009


At http://bzr.arbash-meinel.com/plugins/dummy_request

------------------------------------------------------------
revno: 4
revision-id: john at arbash-meinel.com-20091212210857-s90lq6333nou1peh
parent: john at arbash-meinel.com-20091212210650-x0vrshjs1oh4dgq0
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: dummy_request
timestamp: Sat 2009-12-12 15:08:57 -0600
message:
  Use a StringIO for the request, which means everything is done in ram.
  
  No temp files to worry about.
-------------- next part --------------
=== modified file '__init__.py'
--- a/__init__.py	2009-12-12 21:06:50 +0000
+++ b/__init__.py	2009-12-12 21:08:57 +0000
@@ -87,25 +87,16 @@
 
     """
 
-    takes_options = [option.Option('keep', help='keep the output files'),
-                     option.Option('stats-file', type=unicode,
+    takes_options = [option.Option('stats-file', type=unicode,
                                    help='Output stream tats here.'),
                     ]
 
-    def run(self, keep=False, stats_file=None):
+    def run(self, stats_file=None):
         b = branch.Branch.open('.')
-        req_fn, req_name = tempfile.mkstemp(prefix='bzr-request-')
-        # resp_fn, resp_name = tempfile.mkstemp(prefix='bzr-response-')
-        self.outf.write('Request file: %s\n' % req_name)
-        #self.outf.write('Response file: %s\n' % resp_name)
-        req_f = os.fdopen(req_fn, 'wb+')
-        # TODO: Make the resp_f a wrapper that tracks throughput,
-        #       alternatively, we could also wrap it around a simple list
-        #       structure, so that we avoid any sort of disk I/O limitations
-        # resp_f = os.fdopen(resp_fn, 'wb+')
         pb = ui.ui_factory.nested_progress_bar()
         if stats_file is not None:
             stats_file = open(stats_file, 'wb')
+        req_f = cStringIO.StringIO()
         resp_f = BlackHoleFile(pb, stats_file)
 
         # We don't have the client ever read the response, we just place the
@@ -139,9 +130,6 @@
                            mb_written / delta_time))
         req_f.close()
         resp_f.close()
-        if not keep:
-            os.remove(req_name)
-            # os.remove(resp_name)
         if stats_file is not None:
             stats_file.close()
 



More information about the bazaar-commits mailing list