Hi - thanks for this.
I am now using the Scheduler to launch a copy of getCO2tonnesPVcombiV3 every hour. I then go in once a day and manually kill the excess copies off. This is a sledgehammer approach! But works.
I can see how your example of Long Running tasks is meant to operate - but my code falls over. For some reason the "from xxxx import yyyyy" is failing to incorporate a method. I am probably using incorrect terminology / directory structure or something.............?
My version of your Longrunning task (viz Eternal.py):
!/usr/bin/python2.7
import logging
import socket
import sys
from getCO2tonnesPVcombiV3.py import getCO2tonnesPVcombiV3
lock_socket = None
def is_lock_free():
global lock_socket
lock_socket = socket.socket(socket.AF_UNIX, socket.SOCK_DGRAM)
try:
lock_id = "planetcooler.getCO2tonnesPVcombiV3"
lock_socket.bind('\0' + lock_id)
logging.debug("Acquired lock %r" % (lock_id,))
return True
except socket.error:
# socket already locked, task must be running
logging.info("Failed to acquirelock %r" % (lock_id,))
return False
if not is_lock_free():
sys.exit()
getCO2tonnesPVcombiV3()
results in:
Traceback (most recent call last):
File "/home/planetcooler/Eternal.py", line 6, in <module>
from getCO2tonnesPVcombiV3.py import getCO2tonnesPVcombiV3
File "/home/planetcooler/getCO2tonnesPVcombiV3.py", line 63, in <module>
response = querier.query(substation_id)
NameError: name 'querier' is not defined
....any pointers gratefully received.........
Nearly there !
Regards and thanks .