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?
Cloud Functions deployment can fail if the entry point to your code, that is, the exported function name, is not specified correctly. Your source code must contain an entry point function that has been correctly specified in your deployment, either via Cloud console or Cloud SDK.
But as we continue to expand the capabilities of Cloud Functions, the number-one friction point of FaaS is the “startup tax,” a.k.a. cold starts: if your function has been scaled down to zero, it can take a few seconds for it to initialize and start serving requests.
A background Cloud Function triggered by something like Cloud Storage should have the following function signature:
def function(data, context):
...
The arguments need to be included even if you aren't using them.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With