[Python-checkins] r71003 - in sandbox/trunk/2to3/lib2to3: main.py refactor.py

benjamin.peterson python-checkins at python.org
Thu Apr 2 01:10:43 CEST 2009


Author: benjamin.peterson
Date: Thu Apr  2 01:10:43 2009
New Revision: 71003

Log:
fix when multiprocessing is not available or used

Modified:
   sandbox/trunk/2to3/lib2to3/main.py
   sandbox/trunk/2to3/lib2to3/refactor.py

Modified: sandbox/trunk/2to3/lib2to3/main.py
==============================================================================
--- sandbox/trunk/2to3/lib2to3/main.py	(original)
+++ sandbox/trunk/2to3/lib2to3/main.py	Thu Apr  2 01:10:43 2009
@@ -133,8 +133,11 @@
         if refactor_stdin:
             rt.refactor_stdin()
         else:
-            rt.refactor(args, options.write, options.doctests_only,
-                        options.processes)
+            if HAVE_MULTIPROCESS:
+                rt.refactor(args, options.write, options.doctests_only,
+                            options.processes)
+            else:
+                rt.refactor(args, options.write, options.doctests_only)
         rt.summarize()
 
     # Return error status (0 if rt.errors is zero)

Modified: sandbox/trunk/2to3/lib2to3/refactor.py
==============================================================================
--- sandbox/trunk/2to3/lib2to3/refactor.py	(original)
+++ sandbox/trunk/2to3/lib2to3/refactor.py	Thu Apr  2 01:10:43 2009
@@ -520,8 +520,8 @@
         def refactor(self, items, write=False, doctests_only=False,
                      num_processes=1):
             if num_processes == 1:
-                super(MultiprocessRefactoringTool, self).refactor(items, write,
-                                                                  doctests_only)
+                return super(MultiprocessRefactoringTool, self).refactor(
+                    items, write, doctests_only)
             if self.queue is not None:
                 raise RuntimeError("already doing multiple processes")
             self.queue = multiprocessing.JoinableQueue()
@@ -553,7 +553,11 @@
                 task = self.queue.get()
 
         def refactor_file(self, *args, **kwargs):
-            self.queue.put((args, kwargs))
+            if self.queue is not None:
+                self.queue.put((args, kwargs))
+            else:
+                return super(MultiprocessRefactoringTool, self).refactor_file(
+                    *args, **kwargs)
 
 
 def diff_texts(a, b, filename):


More information about the Python-checkins mailing list