Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(39370)

Side by Side Diff: Lib/test/test_concurrent_futures.py

Issue 27664: Allow specifying prefix for thread name in concurrent.futures.ThreadPoolExecutor
Patch Set: Created 3 years, 1 month ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « Lib/concurrent/futures/thread.py ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 import test.support 1 import test.support
2 2
3 # Skip tests if _multiprocessing wasn't built. 3 # Skip tests if _multiprocessing wasn't built.
4 test.support.import_module('_multiprocessing') 4 test.support.import_module('_multiprocessing')
5 # Skip tests if sem_open implementation is broken. 5 # Skip tests if sem_open implementation is broken.
6 test.support.import_module('multiprocessing.synchronize') 6 test.support.import_module('multiprocessing.synchronize')
7 # import threading after _multiprocessing to raise a more revelant error 7 # import threading after _multiprocessing to raise a more revelant error
8 # message: "No module named _multiprocessing". _multiprocessing is not compiled 8 # message: "No module named _multiprocessing". _multiprocessing is not compiled
9 # without thread support. 9 # without thread support.
10 test.support.import_module('threading') 10 test.support.import_module('threading')
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 for t in executor._threads: 145 for t in executor._threads:
146 t.join() 146 t.join()
147 147
148 def test_del_shutdown(self): 148 def test_del_shutdown(self):
149 executor = futures.ThreadPoolExecutor(max_workers=5) 149 executor = futures.ThreadPoolExecutor(max_workers=5)
150 executor.map(abs, range(-5, 5)) 150 executor.map(abs, range(-5, 5))
151 threads = executor._threads 151 threads = executor._threads
152 del executor 152 del executor
153 153
154 for t in threads: 154 for t in threads:
155 t.join()
156
157 def test_thread_names(self):
158 executor = futures.ThreadPoolExecutor(
159 max_workers=5, thread_name_prefix='SpecialPool')
160 executor.map(abs, range(-5, 5))
161 threads = executor._threads
162 del executor
163
164 for t in threads:
165 self.assertRegex(t.name, '^SpecialPool_[0-4]$')
155 t.join() 166 t.join()
156 167
157 168
158 class ProcessPoolShutdownTest(ProcessPoolMixin, ExecutorShutdownTest, unittest.T estCase): 169 class ProcessPoolShutdownTest(ProcessPoolMixin, ExecutorShutdownTest, unittest.T estCase):
159 def _prime_executor(self): 170 def _prime_executor(self):
160 pass 171 pass
161 172
162 def test_processes_terminate(self): 173 def test_processes_terminate(self):
163 self.executor.submit(mul, 21, 2) 174 self.executor.submit(mul, 21, 2)
164 self.executor.submit(mul, 6, 7) 175 self.executor.submit(mul, 6, 7)
(...skipping 566 matching lines...) Expand 10 before | Expand all | Expand 10 after
731 742
732 @test.support.reap_threads 743 @test.support.reap_threads
733 def test_main(): 744 def test_main():
734 try: 745 try:
735 test.support.run_unittest(__name__) 746 test.support.run_unittest(__name__)
736 finally: 747 finally:
737 test.support.reap_children() 748 test.support.reap_children()
738 749
739 if __name__ == "__main__": 750 if __name__ == "__main__":
740 test_main() 751 test_main()
OLDNEW
« no previous file with comments | « Lib/concurrent/futures/thread.py ('k') | no next file » | no next file with comments »

RSS Feeds Recent Issues | This issue
This is Rietveld 894c83f36cb7+