Calls a specified function.


You can exchange information between processes or functions by calling functions or publishing messages. The differences between calling functions and publishing messages are:

  • The exchange of messages in a function call is bidirectional. After the caller sends a message to the receiver, the caller will receive the message returned by the receiver.
  • Publishing messages is unidirectional. The sender does not need a response from the receiver.


Table 1. Request parameters
Parameter Type Description
params dict The parameter object. For more information, see the table Parameter descriptions of params.
Table 2. Parameter descriptions of params
Parameter Type Description
serviceName String The service name. It is the name of the service to which the function belongs in Alibaba Cloud Function Compute.
functionName String The function name that is defined in Alibaba Cloud Function Compute.
invocationType String The type of the function call.
  • Sync: synchronous
  • Async: asynchronous
This is a synchronous call by default.
payload String|Bytes The input parameter information of the function.
Table 3. Response parameters
Parameter Type Description
return dict The return value of the called function.

Sample requests

  • Sample code for calling a function

    In the code, the function with serviceName=EdgeFC and functionName=helloworld is called.

    # -*- coding: utf-8 -*-
    import lecoresdk
    edgefc = lecoresdk.Client()
    def handler(event, context):
      context = {"custom": {"data": "customData"}}
      invokeParams = {
        "serviceName": 'EdgeFC',
        "functionName": 'helloworld',
        "invocationType": 'Sync',
        "invokerContext": context,
        "payload": 'String message from Python Invoker.'
      res = edgefc.invoke_function(invokeParams)
      return 'OK'
  • Sample code of a function to be called

    The following helloworld function code indicates how a called function parses input parameters from the caller and returns the result to the caller.

    # -*- coding: utf-8 -*-
    import logging
    import lecoresdk
    def handler(event, context):
      return 'hello world'