mlflow/mlflow · error · MlflowException
Served PyFunc Model is missing server process ID.
Error message
Served PyFunc Model is missing server process ID.
What it means
`_ServedPyFuncModel.pid` returns the OS process ID of the scoring-server subprocess, stored in `_server_pid`. If the server process was never started or its PID was never recorded (None), accessing `.pid` raises MlflowException rather than returning None.
Source
Thrown at mlflow/pyfunc/__init__.py:1244
data: Model input data.
params: Additional parameters to pass to the model for inference.
Returns:
Model predictions.
"""
if "params" in inspect.signature(self._client.invoke).parameters:
result = self._client.invoke(data, params=params).get_predictions()
else:
_log_warning_if_params_not_in_predict_signature(_logger, params)
result = self._client.invoke(data).get_predictions()
if isinstance(result, pandas.DataFrame):
result = result[result.columns[0]]
return result
@property
def pid(self):
if self._server_pid is None:
raise MlflowException("Served PyFunc Model is missing server process ID.")
return self._server_pid
@property
def env_manager(self):
return self._env_manager
@env_manager.setter
def env_manager(self, value):
self._env_manager = value
def _load_model_or_server(
model_uri: str, env_manager: str, model_config: dict[str, Any] | None = None
):
"""
Load a model with env restoration. If a non-local ``env_manager`` is specified, prepare an
independent Python environment with the training time dependencies of the specified model
installed and start a MLflow Model Scoring Server process with that model in that environment.View on GitHub (pinned to 6a27f2decc)
Solutions
- Only access `.pid` while the served model is running and healthy (e.g. after a successful predict call)
- Check `_server_pid is not None` before reading `.pid`
- If the server failed to launch, first diagnose the launch failure (see the 'failed to launch' error) and re-invoke load_model with env_manager
- Re-create the served model via `mlflow.pyfunc.load_model(model_uri, env_manager='uv')`
Example fix
// before
pid = served.pid # raises if server missing
// after
if served._server_pid is not None:
pid = served.pid Defensive patterns
Strategy: type-guard
Validate before calling
if served_model._server_pid is None:
raise RuntimeError("scoring server is not running; cannot get pid") Type guard
def server_is_running(served) -> bool:
import psutil
return served._server_pid is not None and psutil.pid_exists(served._server_pid) Try / catch
try:
pid = served.pid
except MlflowException:
pid = None # server not launched or already terminated
restart_server() Prevention
- Only access .pid while the served model is live
- Confirm load_model with env_manager completed successfully first
- Check server health (predict round-trip) before inspecting pid
- Guard against races with server shutdown
When it happens
Trigger: Accessing `.pid` on a `_ServedPyFuncModel` that was constructed without a running server process — e.g. the server failed to launch, was already torn down, or the object was created directly with server_pid=None.
Common situations: Inspecting `.pid` after a failed model-server launch; accessing `.pid` on a served-model object obtained via `mlflow.pyfunc.load_model(..., env_manager=...)` after the server exited or before it started; race with server shutdown.
Related errors
- INVALID_PARAMETER_VALUE
- Unsupported input type: {type(data)}. It must be one of [str
- This container only supports models with the PyFunc flavors.
- Failed to install serving dependencies into the model enviro
- Failed to install mlflow into the model environment.
AI-assisted analysis of mlflow/mlflow@6a27f2decc (2026-08-29).
Data as JSON: /api/errors/9b8196e7e952057c.
Report an issue: GitHub.