github-actions[bot] commented on code in PR #41123:
URL: https://github.com/apache/beam/pull/41123#discussion_r4515633663
##########
sdks/python/apache_beam/transforms/core_test.py:
##########
@@ -797,6 +797,35 @@ def test_none_type_for_field_raises_error(self):
beam.Create([beam.Row(a=None), beam.Row(a=None)]).infer_output_type(None)
+class SubprocessDoFnTest(unittest.TestCase):
+ def test_call_remote_retries_broken_process_pool_on_init(self):
+ import concurrent.futures
+ from unittest import mock
+
+ dofn = beam.core._SubprocessDoFn(beam.core.CallableWrapperDoFn(lambda x:
x))
+ dofn.setup()
+
+ broken_future = concurrent.futures.Future()
+ broken_future.set_exception(
+ concurrent.futures.process.BrokenProcessPool('init crash'))
+ ok_init_future = concurrent.futures.Future()
+ ok_init_future.set_result(None)
+ ok_proc_future = concurrent.futures.Future()
+ ok_proc_future.set_result(['ok'])
+
+ pool1 = mock.MagicMock(_processes={})
+ pool1.submit.return_value = broken_future
+ pool2 = mock.MagicMock(_processes={})
+ pool2.submit.side_effect = [ok_init_future, ok_proc_future]
+
+ with mock.patch('concurrent.futures.ProcessPoolExecutor',
+ side_effect=[pool1, pool2]) as mock_executor:
+ self.assertEqual(dofn.process('elem'), ['ok'])
+ self.assertEqual(mock_executor.call_count, 2)
+ pool1.shutdown.assert_called_once_with(False)
Review Comment:
**🔴 Critical**: `_SubprocessDoFn._terminate_pool()` calls
`pool.shutdown(wait=False)` using a keyword argument (line 2718 of `core.py`).
Because `pool1` is an unspec'd `MagicMock`, asserting
`assert_called_once_with(False)` with a positional argument will fail with
`AssertionError: expected call not found. Expected: shutdown(False) Actual:
shutdown(wait=False)`.
```suggestion
pool1.shutdown.assert_called_once_with(wait=False)
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]