Skip to content

Commit

Permalink
Enable timeout setting for Python TestPipeline (#29646)
Browse files Browse the repository at this point in the history
  • Loading branch information
Naseer-010 committed Feb 5, 2025
1 parent b69b703 commit 11c88c2
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions sdks/python/apache_beam/testing/test_pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,8 @@ def __init__(
is_integration_test=False,
blocking=True,
additional_pipeline_args=None,
display_data=None):
display_data=None,
timeout=None):
"""Initialize a pipeline object for test.
Args:
Expand All @@ -96,6 +97,7 @@ def __init__(
included when construction the pipeline options object.
display_data (Dict[str, Any]): a dictionary of static data associated
with this pipeline that can be displayed when it runs.
timeout (float optional): The time in seconds to wait for the pipeline to finish
Raises:
ValueError: if either the runner or options argument is not
Expand All @@ -107,6 +109,7 @@ def __init__(
self.options_list = (
self._parse_test_option_args(argv) + additional_pipeline_args)
self.blocking = blocking
self.timeout = timeout
if options is None:
options = PipelineOptions(self.options_list)
super().__init__(runner, options, display_data=display_data)
Expand All @@ -116,7 +119,7 @@ def run(self, test_runner_api=True):
test_runner_api=(
False if self.not_use_test_runner_api else test_runner_api))
if self.blocking:
state = result.wait_until_finish()
state = result.wait_until_finish(timeout=self.timeout)
assert state in (PipelineState.DONE, PipelineState.CANCELLED), \
"Pipeline execution failed."

Expand Down

0 comments on commit 11c88c2

Please sign in to comment.