PyHannes
12/17/2025, 10:47 AMMarvin
12/17/2025, 10:47 AMMarvin
12/17/2025, 10:54 AMprefect worker ls/inspect (the worker CLI only has start).
- prefect work-pool inspect and prefect work-queue commands do not list workers.
API (Python client)
- You can query workers for a specific work pool via the Prefect client. Example:
from prefect.client.orchestration import get_client
from prefect.client.schemas.filters import WorkerFilter, WorkerFilterStatus
async def list_workers(pool_name: str):
async with get_client() as client:
workers = await client._work_pool_client.read_workers_for_work_pool(
work_pool_name=pool_name,
worker_filter=WorkerFilter(
status=WorkerFilterStatus(any_=["ONLINE", "OFFLINE"])
),
offset=0,
limit=200,
)
for w in workers:
print(w.name, w.status, w.last_heartbeat_time)
Notes:
- Fields available include: name, status (ONLINE/OFFLINE), last_heartbeat_time, heartbeat_interval_seconds, plus standard ids/timestamps.
- The server does not track which specific work queues a worker is polling, so you can’t filter workers by queue.
API (REST)
- List/filter workers for a pool:
- POST /work_pools/{work_pool_name}/workers/filter
- Example:
curl -X POST "$PREFECT_API_URL/api/work_pools/my-pool/workers/filter" \
-H "Authorization: Bearer $PREFECT_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"workers": {
"status": { "any_": ["ONLINE"] }
},
"offset": 0,
"limit": 100
}'
- Delete a worker:
- DELETE /work_pools/{work_pool_name}/workers/{name}
If you’re specifically trying to find “workers for a queue,” that’s not exposed because the server doesn’t persist which queues a given worker is polling. If you can share what you want to do with queue-level visibility, I can suggest a practical workaround.