Fixing more tests using multiprocessing on Windows

This commit is contained in:
Ben Vanik 2012-05-17 20:10:46 -07:00
parent 04be5f1180
commit 05038116f0
3 changed files with 15 additions and 8 deletions

View File

@ -358,6 +358,8 @@ class MultiProcessTaskExecutor(TaskExecutor):
""" """
super(MultiProcessTaskExecutor, self).__init__(*args, **kwargs) super(MultiProcessTaskExecutor, self).__init__(*args, **kwargs)
self.worker_count = worker_count self.worker_count = worker_count
self._waiting_deferreds = {}
try: try:
self._pool = multiprocessing.Pool(processes=self.worker_count, self._pool = multiprocessing.Pool(processes=self.worker_count,
initializer=_task_initializer) initializer=_task_initializer)
@ -367,9 +369,8 @@ class MultiProcessTaskExecutor(TaskExecutor):
if sys.platform == 'cygwin': if sys.platform == 'cygwin':
print ('Cygwin has known issues with multiprocessing and there\'s no ' print ('Cygwin has known issues with multiprocessing and there\'s no '
'workaround. Boo!') 'workaround. Boo!')
print 'Try running with -j 1 to disable multiprocessing' print 'Try running with -j1 to disable multiprocessing'
raise raise
self._waiting_deferreds = {}
def run_task_async(self, task): def run_task_async(self, task):
if self.closed: if self.closed:

View File

@ -144,7 +144,7 @@ class WhichTest(unittest2.TestCase):
self.assertIsNotNone(util.which('notepad.exe')) self.assertIsNotNone(util.which('notepad.exe'))
@unittest2.skipIf(sys.platform.startswith('win'), 'platform') @unittest2.skipIf(sys.platform.startswith('win'), 'platform')
def testLinux(self): def testUnix(self):
self.assertEqual(util.which('/bin/sh'), '/bin/sh') self.assertEqual(util.which('/bin/sh'), '/bin/sh')
self.assertIsNone(util.which('xxx')) self.assertIsNone(util.which('xxx'))
self.assertIsNotNone(util.which('cat')) self.assertIsNotNone(util.which('cat'))

View File

@ -13,9 +13,15 @@ __author__ = 'benvanik@google.com (Ben Vanik)'
import os import os
import sys import sys
# Add self to the root search path
sys.path.insert(0, os.path.abspath(os.path.dirname(__file__)))
# Run the tests def main():
import anvil.test # Add self to the root search path
anvil.test.main() sys.path.insert(0, os.path.abspath(os.path.dirname(__file__)))
# Run the tests
import anvil.test
anvil.test.main()
if __name__ == '__main__':
main()