|
2 | 2 | import threading |
3 | 3 |
|
4 | 4 | from pebble import concurrent |
| 5 | +from pebble import ThreadPool |
5 | 6 |
|
6 | 7 |
|
7 | 8 | def not_decorated(argument, keyword_argument=0): |
@@ -44,6 +45,11 @@ def daemon_keyword_decorated(): |
44 | 45 | return threading.current_thread().daemon |
45 | 46 |
|
46 | 47 |
|
| 48 | +@concurrent.thread(pool=ThreadPool(1)) |
| 49 | +def pool_decorated(_argument, _keyword_argument=0): |
| 50 | + return threading.current_thread().ident |
| 51 | + |
| 52 | + |
47 | 53 | class ThreadConcurrentObj: |
48 | 54 | a = 0 |
49 | 55 |
|
@@ -130,7 +136,7 @@ def test_error_returned(self): |
130 | 136 | self.assertIsInstance(future.result(), RuntimeError) |
131 | 137 |
|
132 | 138 | def test_error_decorated_callback(self): |
133 | | - """Thread errors are forwarded to callback.""" |
| 139 | + """Thread errors are forwarded to callback.""" |
134 | 140 | future = error_decorated() |
135 | 141 | future.add_done_callback(self.callback) |
136 | 142 | self.event.wait(timeout=1) |
@@ -163,3 +169,9 @@ def test_daemon_keyword_decorated(self): |
163 | 169 | f = daemon_keyword_decorated() |
164 | 170 | dec_out = f.result() |
165 | 171 | self.assertEqual(dec_out, False) |
| 172 | + |
| 173 | + def test_pool_decorated(self): |
| 174 | + """Thread pool decorated function.""" |
| 175 | + future1 = pool_decorated(1, 1) |
| 176 | + future2 = pool_decorated(1, 1) |
| 177 | + self.assertEqual(future1.result(), future2.result()) |
0 commit comments