Skip to content

ShellOperation continues running after cancelling a flow run when using process type work pool #20979

@gediminasz

Description

@gediminasz

Bug summary

Example flow:

from prefect import flow
from prefect_shell import ShellOperation


@flow
def sleepy():
    ShellOperation(commands=["sleep 9999"]).run()

Steps to reproduce:

# 1. set up project
uv init
uv add prefect[shell]
export PREFECT_API_URL=http://localhost:4200/api

# 2. start the prefect server
uv run prefect server start

# 3. set up a *process type* work pool and a worker
uv run prefect work-pool create --name test --type process
uv run prefect worker start --pool test

# 4. deploy and run the flow
uv run prefect --no-prompt deploy main.py:sleepy --name test --pool test
uv run prefect deployment run 'sleepy/test'

# 5. wait for the flow run to start

# 6. cancel the flow run via web UI

# 7. observe orphaned `sleep 9999` process is still running:
pgrep -a sleep

Possibly related: #17593

Version info

Version:              3.6.20
API version:          0.8.4
Python version:       3.14.2
Git commit:           395392ae
Built:                Fri, Feb 27, 2026 05:34 PM
OS/Arch:              linux/x86_64
Profile:              ephemeral
Server type:          ephemeral
Pydantic version:     2.12.5
Server:
  Database:           sqlite
  SQLite version:     3.50.4
Integrations:
  prefect-shell:      0.3.3

Additional context

I would look into having the prefect worker kill the process group instead.

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions