Back to index

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

List of all members.

Public Member Functions

def setUp
def tearDown
def test_no_timeout
def test_zero_timeout

Public Attributes

 t1
 executor

Static Public Attributes

 executor_type = futures.ThreadPoolExecutor
int worker_count = 5

Detailed Description

Definition at line 326 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 290 of file test_concurrent_futures.py.

00290 
00291     def test_no_timeout(self):
00292         future1 = self.executor.submit(mul, 2, 21)
00293         future2 = self.executor.submit(mul, 7, 6)
00294 
00295         completed = set(futures.as_completed(
00296                 [CANCELLED_AND_NOTIFIED_FUTURE,
00297                  EXCEPTION_FUTURE,
00298                  SUCCESSFUL_FUTURE,
00299                  future1, future2]))
00300         self.assertEqual(set(
00301                 [CANCELLED_AND_NOTIFIED_FUTURE,
00302                  EXCEPTION_FUTURE,
00303                  SUCCESSFUL_FUTURE,
00304                  future1, future2]),
00305                 completed)

Here is the call graph for this function:

Definition at line 306 of file test_concurrent_futures.py.

00306 
00307     def test_zero_timeout(self):
00308         future1 = self.executor.submit(time.sleep, 2)
00309         completed_futures = set()
00310         try:
00311             for future in futures.as_completed(
00312                     [CANCELLED_AND_NOTIFIED_FUTURE,
00313                      EXCEPTION_FUTURE,
00314                      SUCCESSFUL_FUTURE,
00315                      future1],
00316                     timeout=0):
00317                 completed_futures.add(future)
00318         except futures.TimeoutError:
00319             pass
00320 
00321         self.assertEqual(set([CANCELLED_AND_NOTIFIED_FUTURE,
00322                               EXCEPTION_FUTURE,
00323                               SUCCESSFUL_FUTURE]),
00324                          completed_futures)
00325 

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: