From 05038116f0f5a37d6e518360e2034d734ee4767f Mon Sep 17 00:00:00 2001 From: Ben Vanik Date: Thu, 17 May 2012 20:10:46 -0700 Subject: [PATCH] Fixing more tests using multiprocessing on Windows --- anvil/task.py | 5 +++-- anvil/util_test.py | 2 +- run-tests.py | 16 +++++++++++----- 3 files changed, 15 insertions(+), 8 deletions(-) diff --git a/anvil/task.py b/anvil/task.py index c333732..618affe 100644 --- a/anvil/task.py +++ b/anvil/task.py @@ -358,6 +358,8 @@ class MultiProcessTaskExecutor(TaskExecutor): """ super(MultiProcessTaskExecutor, self).__init__(*args, **kwargs) self.worker_count = worker_count + self._waiting_deferreds = {} + try: self._pool = multiprocessing.Pool(processes=self.worker_count, initializer=_task_initializer) @@ -367,9 +369,8 @@ class MultiProcessTaskExecutor(TaskExecutor): if sys.platform == 'cygwin': print ('Cygwin has known issues with multiprocessing and there\'s no ' 'workaround. Boo!') - print 'Try running with -j 1 to disable multiprocessing' + print 'Try running with -j1 to disable multiprocessing' raise - self._waiting_deferreds = {} def run_task_async(self, task): if self.closed: diff --git a/anvil/util_test.py b/anvil/util_test.py index 25491eb..ceebd8e 100755 --- a/anvil/util_test.py +++ b/anvil/util_test.py @@ -144,7 +144,7 @@ class WhichTest(unittest2.TestCase): self.assertIsNotNone(util.which('notepad.exe')) @unittest2.skipIf(sys.platform.startswith('win'), 'platform') - def testLinux(self): + def testUnix(self): self.assertEqual(util.which('/bin/sh'), '/bin/sh') self.assertIsNone(util.which('xxx')) self.assertIsNotNone(util.which('cat')) diff --git a/run-tests.py b/run-tests.py index b354811..56b963e 100755 --- a/run-tests.py +++ b/run-tests.py @@ -13,9 +13,15 @@ __author__ = 'benvanik@google.com (Ben Vanik)' import os import sys -# Add self to the root search path -sys.path.insert(0, os.path.abspath(os.path.dirname(__file__))) -# Run the tests -import anvil.test -anvil.test.main() +def main(): + # Add self to the root search path + sys.path.insert(0, os.path.abspath(os.path.dirname(__file__))) + + # Run the tests + import anvil.test + anvil.test.main() + + +if __name__ == '__main__': + main()