In Prefect 3.x, a "worker" is a lightweight polling service that retrieves scheduled runs from a work pool and executes them. Workers are responsible for provisioning the flow run infrastructure and can only poll work pools that match their type. Each worker type corresponds to a specific execution environment.
When you run a Python script and call "serve," it's not inherently considered a worker in the Prefect context. Workers are specifically designed to handle flow runs by polling work pools. The "serve" function typically relates to serving a FastAPI application or similar, not directly related to Prefect's worker concept.
For more details on workers in Prefect, you can refer to
this documentation.