Skip to content

Commit 238e134

Browse files
committed
Add a test.
1 parent bcf712a commit 238e134

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

Lib/test/test_concurrent_futures/test_interpreter_pool.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,16 @@ def pipe(self):
5656
return r, w
5757

5858

59+
class Shenanigans:
60+
"""Succeeds with pickle.dumps(), but fails with pickle.loads()"""
61+
def __init__(self, value):
62+
if value == 1:
63+
raise RuntimeError("gotcha")
64+
65+
def __reduce__(self):
66+
return (self.__class__, (1,))
67+
68+
5969
class InterpreterPoolExecutorTest(
6070
InterpretersMixin, ExecutorTest, BaseTestCase):
6171

@@ -279,6 +289,14 @@ def test_idle_thread_reuse(self):
279289
self.assertEqual(len(executor._threads), 1)
280290
executor.shutdown(wait=True)
281291

292+
def test_pickle_errors_propagate(self):
293+
# GH-125864: Pickle errors happen before the script tries to execute, so the
294+
# queue used to wait infinitely.
295+
296+
fut = self.executor.submit(Shenanigans(0))
297+
with self.assertRaisesRegex(RuntimeError, "gotcha"):
298+
fut.result()
299+
282300

283301
class AsyncioTest(InterpretersMixin, testasyncio_utils.TestCase):
284302

@@ -351,6 +369,7 @@ def test_default_executor(self):
351369
self.assertNotEqual(interpid, unexpected)
352370

353371

372+
354373
def setUpModule():
355374
setup_module()
356375

0 commit comments

Comments
 (0)