aaaaaaarghhhhhhhh

This commit is contained in:
Jan-Ole Hübner 2024-08-18 00:21:28 +02:00
parent 877cda9640
commit 9fa7581574
2 changed files with 4 additions and 23 deletions

View file

@ -1,22 +1,8 @@
async def periodic_task():
while True:
try:
# Fetch price info and write to InfluxDB
p = Price(home.current_subscription.price_info.current).get_datapoint()
write_api.write(record=p, bucket=BUCKET)
logger.info(vars(p))
except Exception as e:
logger.exception("Error in periodic_task():")
# Wait for the next run (e.g., every 60 seconds)
await asyncio.sleep(3)
import asyncio
import os
import signal
import sys
import time
import tibber
from influxdb_client import InfluxDBClient
@ -41,7 +27,7 @@ logger.setLevel(logging.INFO)
__version__ = "v0.3.4"
logger.info(__version__)
loop = asyncio.get_event_loop()
logger.info("connecting to db...")
client = InfluxDBClient(url=URL, token=TOKEN, org=ORG)
@ -76,9 +62,6 @@ try:
signal.signal(signal.SIGALRM, timeout_handler)
signal.alarm(15)
home.start_live_feed(user_agent="pulse.py/0.3.4",exit_condition=stop(home),retries=2,retry_interval=3.0)
periodic_task_task = loop.create_task(periodic_task())
# Wait for both tasks to complete
except TypeError:
logger.exception("Timeout occurred while executing start_live_feed()")
client.close()
@ -93,5 +76,3 @@ except Exception:

View file

@ -5,8 +5,8 @@ python3 /app/pulse.py &
# Run the other script periodically in the background
(
while true; do
python3 /app/get_price.py >> /var/log/other_script.log 2>&1
sleep 3 # Sleep for 60 seconds (1 minute)
python3 /app/get_price.py
sleep 900
done
) &