python - 通过 Python 使用 Google Cloud Function 时,我可以部署一个常用函数吗?

标签 python google-cloud-platform google-cloud-functions

我已经创建了一个Common类,将被common使用,正在从A函数和B函数接近。

如果我将变量添加到 Common 类,则必须同时部署 A 和 B 类。

如何在不部署所有A和B功能的情况下应用Common类生效?

class Common:
    def __init__(self, tmp):
        self.FIRST = tmp
        self.SECOND = 'Test' # new.

    # I want to modify this function.
    # but I have to deploy function A and B.
    # If I have a lot of functions I need a lot of time.
    def print_value(self):
        print(self.FIRST) # old.
        print(self.FIRST, self.SECOND) # new.

class A:
    def __init__(self):
        o = Common('A')
        o.print_value()

class B:
    def __init__(self):
        o = Common('B')
        o.print_value()

最佳答案

这是不可能的:每个 Cloud Function 的来源都与任何其他 Cloud Function 完全分开。

如果您总是希望同时部署这些功能,您可能需要考虑将它们转换为应用程序中的端点并将其部署到 Cloud Run相反。

关于python - 通过 Python 使用 Google Cloud Function 时,我可以部署一个常用函数吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60334291/

相关文章:

google-cloud-platform - 使用 GCP 后端访问 Google Colab 中的驱动器时出错

javascript - 检查 child 的数量是否大于1

部署函数时 Firebase CLI 不起作用。错误 : HTTP Error: 404, 找不到方法

php - PHP 中 Python 的 Lambda 等效项

python - OpenCV 特定颜色提取

python - 尝试访问存储桶存储中存在的 Google Cloud 中的文件时出现 FileNotFoundError

google-cloud-storage - 如何更新 .boto 文件中的项目 ID

python - 通过文件读/写与Python代码交互?

python - 如何在 Ubuntu 12.10 上安装 Google App 引擎?

google-cloud-platform - 从 Node.js Cloud Function 创建 Kubernetes 作业