Back to index

python3.2  3.2.2
Public Member Functions | Public Attributes | Static Public Attributes
test.test_concurrent_futures.ThreadPoolWaitTests Class Reference
Inheritance diagram for test.test_concurrent_futures.ThreadPoolWaitTests:
Inheritance graph
[legend]
Collaboration diagram for test.test_concurrent_futures.ThreadPoolWaitTests:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def setUp
def tearDown
def test_first_completed
def test_first_completed_some_already_completed
def test_first_exception
def test_first_exception_some_already_complete
def test_first_exception_one_already_failed
def test_all_completed
def test_timeout

Public Attributes

 t1
 executor

Static Public Attributes

 executor_type = futures.ThreadPoolExecutor
int worker_count = 5

Detailed Description

Definition at line 280 of file test_concurrent_futures.py.


Member Function Documentation

Definition at line 58 of file test_concurrent_futures.py.

00058 
00059     def setUp(self):
00060         self.t1 = time.time()
00061         try:
00062             self.executor = self.executor_type(max_workers=self.worker_count)
00063         except NotImplementedError as e:
00064             self.skipTest(str(e))
00065         self._prime_executor()

Here is the caller graph for this function:

Definition at line 66 of file test_concurrent_futures.py.

00066 
00067     def tearDown(self):
00068         self.executor.shutdown(wait=True)
00069         dt = time.time() - self.t1
00070         if test.support.verbose:
00071             print("%.2fs" % dt, end=' ')
00072         self.assertLess(dt, 60, "synchronization issue: test lasted too long")

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 242 of file test_concurrent_futures.py.

00242 
00243     def test_all_completed(self):
00244         future1 = self.executor.submit(divmod, 2, 0)
00245         future2 = self.executor.submit(mul, 2, 21)
00246 
00247         finished, pending = futures.wait(
00248                 [SUCCESSFUL_FUTURE,
00249                  CANCELLED_AND_NOTIFIED_FUTURE,
00250                  EXCEPTION_FUTURE,
00251                  future1,
00252                  future2],
00253                 return_when=futures.ALL_COMPLETED)
00254 
00255         self.assertEqual(set([SUCCESSFUL_FUTURE,
00256                               CANCELLED_AND_NOTIFIED_FUTURE,
00257                               EXCEPTION_FUTURE,
00258                               future1,
00259                               future2]), finished)
00260         self.assertEqual(set(), pending)

Here is the call graph for this function:

Definition at line 181 of file test_concurrent_futures.py.

00181 
00182     def test_first_completed(self):
00183         future1 = self.executor.submit(mul, 21, 2)
00184         future2 = self.executor.submit(time.sleep, 1.5)
00185 
00186         done, not_done = futures.wait(
00187                 [CANCELLED_FUTURE, future1, future2],
00188                  return_when=futures.FIRST_COMPLETED)
00189 
00190         self.assertEqual(set([future1]), done)
00191         self.assertEqual(set([CANCELLED_FUTURE, future2]), not_done)

Here is the call graph for this function:

Definition at line 192 of file test_concurrent_futures.py.

00192 
00193     def test_first_completed_some_already_completed(self):
00194         future1 = self.executor.submit(time.sleep, 1.5)
00195 
00196         finished, pending = futures.wait(
00197                  [CANCELLED_AND_NOTIFIED_FUTURE, SUCCESSFUL_FUTURE, future1],
00198                  return_when=futures.FIRST_COMPLETED)
00199 
00200         self.assertEqual(
00201                 set([CANCELLED_AND_NOTIFIED_FUTURE, SUCCESSFUL_FUTURE]),
00202                 finished)
00203         self.assertEqual(set([future1]), pending)

Here is the call graph for this function:

Definition at line 204 of file test_concurrent_futures.py.

00204 
00205     def test_first_exception(self):
00206         future1 = self.executor.submit(mul, 2, 21)
00207         future2 = self.executor.submit(sleep_and_raise, 1.5)
00208         future3 = self.executor.submit(time.sleep, 3)
00209 
00210         finished, pending = futures.wait(
00211                 [future1, future2, future3],
00212                 return_when=futures.FIRST_EXCEPTION)
00213 
00214         self.assertEqual(set([future1, future2]), finished)
00215         self.assertEqual(set([future3]), pending)

Here is the call graph for this function:

Definition at line 232 of file test_concurrent_futures.py.

00232 
00233     def test_first_exception_one_already_failed(self):
00234         future1 = self.executor.submit(time.sleep, 2)
00235 
00236         finished, pending = futures.wait(
00237                  [EXCEPTION_FUTURE, future1],
00238                  return_when=futures.FIRST_EXCEPTION)
00239 
00240         self.assertEqual(set([EXCEPTION_FUTURE]), finished)
00241         self.assertEqual(set([future1]), pending)

Here is the call graph for this function:

Definition at line 216 of file test_concurrent_futures.py.

00216 
00217     def test_first_exception_some_already_complete(self):
00218         future1 = self.executor.submit(divmod, 21, 0)
00219         future2 = self.executor.submit(time.sleep, 1.5)
00220 
00221         finished, pending = futures.wait(
00222                 [SUCCESSFUL_FUTURE,
00223                  CANCELLED_FUTURE,
00224                  CANCELLED_AND_NOTIFIED_FUTURE,
00225                  future1, future2],
00226                 return_when=futures.FIRST_EXCEPTION)
00227 
00228         self.assertEqual(set([SUCCESSFUL_FUTURE,
00229                               CANCELLED_AND_NOTIFIED_FUTURE,
00230                               future1]), finished)
00231         self.assertEqual(set([CANCELLED_FUTURE, future2]), pending)

Here is the call graph for this function:

Definition at line 261 of file test_concurrent_futures.py.

00261 
00262     def test_timeout(self):
00263         future1 = self.executor.submit(mul, 6, 7)
00264         future2 = self.executor.submit(time.sleep, 3)
00265 
00266         finished, pending = futures.wait(
00267                 [CANCELLED_AND_NOTIFIED_FUTURE,
00268                  EXCEPTION_FUTURE,
00269                  SUCCESSFUL_FUTURE,
00270                  future1, future2],
00271                 timeout=1.5,
00272                 return_when=futures.ALL_COMPLETED)
00273 
00274         self.assertEqual(set([CANCELLED_AND_NOTIFIED_FUTURE,
00275                               EXCEPTION_FUTURE,
00276                               SUCCESSFUL_FUTURE,
00277                               future1]), finished)
00278         self.assertEqual(set([future2]), pending)
00279 

Here is the call graph for this function:


Member Data Documentation

Definition at line 61 of file test_concurrent_futures.py.

test.test_concurrent_futures.ThreadPoolMixin.executor_type = futures.ThreadPoolExecutor [static, inherited]

Definition at line 84 of file test_concurrent_futures.py.

Definition at line 59 of file test_concurrent_futures.py.

Definition at line 56 of file test_concurrent_futures.py.


The documentation for this class was generated from the following file: