Google Cloud Functions - Why are two positional ar

2019-05-02 06:43发布

I have a Google Cloud Function on Python 3.7 that does not take any input arguments. When I try to run it, it gives the following error:

TypeError: google_cloud_function() takes 0 positional arguments but 2 were given

The actual function code looks something like this (with different bash functions called):

import subprocess

def google_cloud_function():
    subprocess.call(["ls"], shell=True)
    subprocess.call(["pwd"], shell=True)

Why would this be the case?

1条回答
三岁会撩人
2楼-- · 2019-05-02 07:30

A background Cloud Function triggered by something like GCS should have the following function signature:

def function(data, context):
    ...

The arguments need to be included even if you aren't using them.

查看更多
登录 后发表回答