A handler is the method in your function code that Function Compute (FC) calls to process requests. Configure a handler to connect your Python code to the FC runtime so your function can receive and respond to invocations.
How handlers work
When FC invokes a Python function, it calls the handler method you specify. The handler receives the incoming request, runs your logic, and returns a response.
Handler naming
For Python functions, set the Request Handler parameter to <filename>.<method_name>.
| Component | Description | Example |
|---|---|---|
filename | Python file name without the .py extension | main |
method_name | Function name inside the file | handler |
For example, if your file is main.py and your method is handler, set Request Handler to main.handler.
To update the handler in the console:
Go to the Function Compute console and open your function.
Find the Request Handler field.
Enter the handler in
filename.method_nameformat, then save.
Handler types
FC supports two handler types. Choose based on how your function is triggered.
| Handler type | Triggered by | Use when |
|---|---|---|
| Event handler | Event sources | Building event-driven workflows |
| HTTP handler | HTTP triggers | Building web APIs or handling HTTP requests directly |
The handler signature differs between the two types. For structure details and examples, see:
For background on event functions and HTTP functions, see Function types.
What's next
Manage functions — create, configure, and delete functions in Function Compute
Deploy a code package — package your Python code and deploy it to Function Compute