-
Notifications
You must be signed in to change notification settings - Fork 4.5k
Adds a pipeline option to terminate processing of an element after a timeout (python) #35391
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 24 commits
0128566
f634e5c
4dbbd32
6fd2641
3e299d7
90975be
cdcf613
a8d232b
5cdea91
2ec2da8
d215625
7023cfb
4a972b5
42e3e9a
fda548e
77b0558
b19f8dc
fd92e18
c1f5f3f
6609ff1
3d48062
8115db5
cf578da
8fea033
04f61eb
76b22e2
3a02cf3
173ae07
673f5c1
41c74b8
0ab9a0b
87c0229
3bc7c69
54e1da8
0d04cef
2a1799a
719bb53
335958d
b8a441e
85e509c
0e5412e
1f73611
ad5126d
90ae9c0
fbe8ca1
01dbee2
dda93bb
6f201f2
92f6fe0
c6eb5b5
6b8ae4c
bdaec05
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -176,6 +176,7 @@ def __init__( | |||||||||||||
| # that should be reported to the runner when proocessing the first bundle. | ||||||||||||||
| deferred_exception=None, # type: Optional[Exception] | ||||||||||||||
| runner_capabilities=frozenset(), # type: FrozenSet[str] | ||||||||||||||
| element_processing_timeout_minutes=None, # type: Optional[int] | ||||||||||||||
| ): | ||||||||||||||
| # type: (...) -> None | ||||||||||||||
| self._alive = True | ||||||||||||||
|
|
@@ -207,6 +208,7 @@ def __init__( | |||||||||||||
| self._profiler_factory = profiler_factory | ||||||||||||||
| self.data_sampler = data_sampler | ||||||||||||||
| self.runner_capabilities = runner_capabilities | ||||||||||||||
| self.element_processing_timeout_minutes = element_processing_timeout_minutes | ||||||||||||||
LEEKYE marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||||||||||||||
|
|
||||||||||||||
| def default_factory(id): | ||||||||||||||
| # type: (str) -> beam_fn_api_pb2.ProcessBundleDescriptor | ||||||||||||||
|
|
@@ -230,7 +232,12 @@ def default_factory(id): | |||||||||||||
| status_address, | ||||||||||||||
| self._bundle_processor_cache, | ||||||||||||||
| self._state_cache, | ||||||||||||||
| enable_heap_dump) # type: Optional[FnApiWorkerStatusHandler] | ||||||||||||||
| enable_heap_dump, | ||||||||||||||
| element_processing_timeout_minutes=self. | ||||||||||||||
| element_processing_timeout_minutes | ||||||||||||||
| ) # type: Optional[FnApiWorkerStatusHandler] | ||||||||||||||
| except TimeoutError as e: | ||||||||||||||
|
||||||||||||||
| except: # pylint: disable=broad-except | |
| _LOGGER.critical('Python sdk harness failed: ', exc_info=True) | |
| raise | |
| finally: | |
| if fn_log_handler: | |
| fn_log_handler.close() |
We could do this:
- make logs handler a process-level global variable
- add a helpers in sdk_worker_main to flush log handler (if defined) + shut down the process. This would be callable from any thread.
- call these from worker_status thread when timeout is reached
Even better would be to catch the expression on the main thread but that requires either message passing from child threads to main thread or refactoring thread management using concurrent.futures.
Uh oh!
There was an error while loading. Please reload this page.