【问题标题】:Python - post in firebasePython - 在firebase中发布
【发布时间】:2019-07-04 08:38:44
【问题描述】:

我想制作一个 python 脚本作为我的 firebase 应用程序的后端。

我想在特定时间在 firebase 中发布一个对象。但它发布了 3,4 或 5 次.. 例如,我只想要一条 jobStoreAllum () 记录。

感谢您的帮助

 from time import sleep
 import time
 import datetime
 from firebase import firebase
 import urllib2, urllib, httplib
 import json
 import os 
 from functools import partial
 firebase = firebase.FirebaseApplication('https://plante-.firebaseio.com/', None)
 import schedule


 def jobAllum():
     x=1
     y=True
     firebase.put("/Interuptors/Elec01", "/value", x)
     firebase.put("/Interuptors/Elec01", "/state", y)

 def jobStoreAllum():
     dateString = '%d/%m/%Y %H:%M:%S'
     y=True
     data = {"State": y,"Horodate":datetime.datetime.now().strftime(dateString) }
     firebase.post('/Storage/Journee', data)


 while True:
     Hallum= firebase.get("/Autom/Prog1/Hallum", None)
     schedule.every().day.at(Hallum).do(jobAllum)
     schedule.every().day.at(Hallum).do(jobStoreAllum)
     schedule.run_pending()
     time.sleep(10)

【问题讨论】:

    标签: python firebase firebase-realtime-database schedule


    【解决方案1】:

    您可以使用 Cloud Scheduler。 确保终止返回值的函数。 并注意函数超时,默认为 1 分钟,最大值为 9 分钟。 您必须为项目启用计费,并且您每月有 3 个免费作业,超过 3 个的收费为 0.10 美元/作业,而不是执行。

    This

    【讨论】:

    • 您仍然可以通过在调度程序中仅创建 1 个作业来摆脱它。我要求支持,他们很清楚地指出您按“创建的工作”付款,而不是执行。或者您可以在您的计算机中创建一个 cron 作业(这就是我开始的方式),这是您的计算机在计划 cron 作业时必须打开的唯一缺点。
    猜你喜欢
    • 2014-07-22
    • 2016-12-03
    • 1970-01-01
    • 2017-08-22
    • 2020-05-30
    • 1970-01-01
    • 2017-09-13
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多