Skip to content

Prefect suspend_flow_run failed #17822

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

Open
HubWu42 opened this issue Apr 15, 2025 · 0 comments
Open

Prefect suspend_flow_run failed #17822

HubWu42 opened this issue Apr 15, 2025 · 0 comments
Labels
bug Something isn't working

Comments

@HubWu42
Copy link

HubWu42 commented Apr 15, 2025

Bug summary

Image

After the 'flow' execution, the function is suspended. The 'flow' state changes, but the execution does not pause and continues. Subsequently, it displays that the 'flow' is not in a paused state.

Version info

prefect v3.3.3
python v3.10

Additional context

`from time import sleep
from prefect import get_client, suspend_flow_run
from prefect.deployments import run_deployment
from prefect.states import Suspended
import asyncio

flow_run_id = "bc8e3580-634a-461e-b3ae-c32780622f4f"

def run_flow() -> str:
try:
flow_run = run_deployment(
name=flow_run_id,
timeout=10
)
print(f"flow_run: {flow_run}")
return str(flow_run.id)
except Exception as e:
print(f"failed: {e}")
return ""

async def suspend_flow(flow_run_id: str) -> bool:
try:
result = await suspend_flow_run(flow_run_id=flow_run_id)
print(f"result: {result}")
return True
except Exception as e:
print(f"suspend_failed: {e}")
return False

async def resume_flow(flow_run_id) -> bool:
try:
async with get_client() as client:
result = await client.resume_flow_run(flow_run_id=flow_run_id)
print(f"resume result: {result}")
return result
except Exception as e:
print(f"resume result: {e}")
return False

if name == "main":
new_run_id = run_flow()
print(f"Flow,Run ID: {new_run_id}")

# result = asyncio.run(resume_flow("3c2cc53b-cbdd-4e0c-a8a8-5843a0d3272c"))


if new_run_id:
    sleep(10)
    if asyncio.run(suspend_flow(new_run_id)):
        print("success")
        if asyncio.run(resume_flow(new_run_id)):
            print("success")`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant