Skip to content
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

Calling suspend_flow_run raises an exception #16915

Closed
EmilRex opened this issue Jan 30, 2025 · 0 comments · Fixed by #17014
Closed

Calling suspend_flow_run raises an exception #16915

EmilRex opened this issue Jan 30, 2025 · 0 comments · Fixed by #17014
Labels
enhancement An improvement of an existing feature

Comments

@EmilRex
Copy link
Contributor

EmilRex commented Jan 30, 2025

Bug summary

Calling suspend_flow_run in a flow raises a prefect.exceptions.Pause exception with an associate stack trace. I would expect it to be caught and not generate a stack trace.

Repro

# repro/suspend.py
from prefect import flow, suspend_flow_run


@flow
def suspend():
    suspend_flow_run(timeout=60)


if __name__ == "__main__":
    suspend.serve(name="served")

Log

python repro/suspend.py  
Your flow 'suspend' is being served and polling for scheduled runs!

To trigger a run for this flow, use the following command:

        $ prefect deployment run 'suspend/served'

You can also run your flow via the Prefect UI: https://app.prefect.cloud/account/0ff44498-d380-4d7b-bd68-9b52da03823f/workspace/6bf6d7a9-ab18-4942-9315-349d4f1fef34/deployments/deployment/3757304d-01de-490c-a8f1-6210cf2df8f2

15:52:34.912 | INFO    | prefect.flow_runs.runner - Runner 'served' submitting flow run 'bf5ca198-1ea5-4b7f-a852-770fd817a44a'
15:52:35.041 | INFO    | prefect.flow_runs.runner - Opening process...
15:52:35.064 | INFO    | prefect.flow_runs.runner - Completed submission of flow run 'bf5ca198-1ea5-4b7f-a852-770fd817a44a'
15:52:36.708 | INFO    | Flow run 'abstract-anteater' - Downloading flow code from storage at '.'
15:52:37.139 | INFO    | Flow run 'abstract-anteater' - Beginning flow run 'abstract-anteater' for flow 'suspend'
15:52:37.140 | INFO    | Flow run 'abstract-anteater' - View at https://app.prefect.cloud/account/0ff44498-d380-4d7b-bd68-9b52da03823f/workspace/6bf6d7a9-ab18-4942-9315-349d4f1fef34/runs/flow-run/bf5ca198-1ea5-4b7f-a852-770fd817a44a
15:52:37.156 | INFO    | Flow run 'abstract-anteater' - Suspending flow run, execution will be rescheduled when this flow run is resumed.
15:52:37.348 | ERROR   | Flow run 'abstract-anteater' - Finished in state Running()
15:52:37.349 | ERROR   | Flow run 'abstract-anteater' - Engine execution exited with unexpected exception
Traceback (most recent call last):
  File "/Users/emilchristensen/github/examples/.venv/lib/python3.12/site-packages/prefect/flow_engine.py", line 1511, in run_flow
    ret_val = run_flow_sync(**kwargs)
              ^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/emilchristensen/github/examples/.venv/lib/python3.12/site-packages/prefect/flow_engine.py", line 1354, in run_flow_sync
    engine.call_flow_fn()
  File "/Users/emilchristensen/github/examples/.venv/lib/python3.12/site-packages/prefect/flow_engine.py", line 766, in call_flow_fn
    result = call_with_parameters(self.flow.fn, self.parameters)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/emilchristensen/github/examples/.venv/lib/python3.12/site-packages/prefect/utilities/callables.py", line 208, in call_with_parameters
    return fn(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^
  File "/Users/emilchristensen/github/examples/repro/suspend.py", line 6, in suspend
    suspend_flow_run(timeout=60)
  File "/Users/emilchristensen/github/examples/.venv/lib/python3.12/site-packages/prefect/utilities/asyncutils.py", line 353, in coroutine_wrapper
    return run_coro_as_sync(ctx_call())
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/emilchristensen/github/examples/.venv/lib/python3.12/site-packages/prefect/utilities/asyncutils.py", line 209, in run_coro_as_sync
    return call.result()
           ^^^^^^^^^^^^^
  File "/Users/emilchristensen/github/examples/.venv/lib/python3.12/site-packages/prefect/_internal/concurrency/calls.py", line 330, in result
    return self.future.result(timeout=timeout)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/emilchristensen/github/examples/.venv/lib/python3.12/site-packages/prefect/_internal/concurrency/calls.py", line 193, in result
    return self.__get_result()
           ^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/[email protected]/3.12.8/Frameworks/Python.framework/Versions/3.12/lib/python3.12/concurrent/futures/_base.py", line 401, in __get_result
    raise self._exception
  File "/Users/emilchristensen/github/examples/.venv/lib/python3.12/site-packages/prefect/_internal/concurrency/calls.py", line 403, in _run_async
    result = await coro
             ^^^^^^^^^^
  File "/Users/emilchristensen/github/examples/.venv/lib/python3.12/site-packages/prefect/utilities/asyncutils.py", line 190, in coroutine_wrapper
    return await task
           ^^^^^^^^^^
  File "/Users/emilchristensen/github/examples/.venv/lib/python3.12/site-packages/prefect/utilities/asyncutils.py", line 343, in ctx_call
    result = await async_fn(*args, **kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/emilchristensen/github/examples/.venv/lib/python3.12/site-packages/prefect/client/utilities.py", line 99, in with_injected_client
    return await fn(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/emilchristensen/github/examples/.venv/lib/python3.12/site-packages/prefect/flow_runs.py", line 429, in suspend_flow_run
    raise Pause()
prefect.exceptions.Pause
15:52:37.356 | INFO    | prefect.engine - Engine execution of flow run 'bf5ca198-1ea5-4b7f-a852-770fd817a44a' is paused:
15:52:37.609 | INFO    | prefect.flow_runs.runner - Process for flow run 'abstract-anteater' exited cleanly.

Version info

Version:             3.1.14
API version:         0.8.4
Python version:      3.12.8
Git commit:          5f1ebb57
Built:               Thu, Jan 23, 2025 1:22 PM
OS/Arch:             darwin/arm64
Profile:             dev
Server type:         cloud
Pydantic version:    2.10.3
Integrations:
  prefect-docker:    0.6.2

Additional context

No response

@EmilRex EmilRex added the bug Something isn't working label Jan 30, 2025
@cicdw cicdw added enhancement An improvement of an existing feature and removed bug Something isn't working labels Feb 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement An improvement of an existing feature
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants