Go back to old loop system & take Radar processing out of the loop

This commit is contained in:
April 2022-10-17 23:52:07 -07:00
parent ab7ff6fca0
commit 51be3229e9
No known key found for this signature in database
GPG Key ID: 17A9A017FAA4DE5E

30
main.py
View File

@ -1,7 +1,8 @@
import asyncio import asyncio
from asyncore import loop
import logging,coloredlogs import logging,coloredlogs
from recordGenerators import DailyForecast,CurrentObservations,HourlyForecast,AirQuality,AirportDelays,PollenForecast,Breathing,Alerts from recordGenerators import DailyForecast,CurrentObservations,HourlyForecast,AirQuality,AirportDelays,PollenForecast,Breathing,Alerts
from radar import TWCRadarProcessor, RadarProcessor # from radar import TWCRadarProcessor, RadarProcessor
l = logging.getLogger(__name__) l = logging.getLogger(__name__)
@ -21,10 +22,12 @@ async def grabAlertsLoop():
Alerts.makeRecord() Alerts.makeRecord()
await asyncio.sleep(60) await asyncio.sleep(60)
async def RadarProcessingLoop():
while True: # THIS IS BROKEN AT THE MOMENT -- COME BACK LATER.
await TWCRadarProcessor.makeRadarImages() # async def RadarProcessingLoop():
await asyncio.sleep(30 * 60) # while True:
# await TWCRadarProcessor.makeRadarImages()
# await asyncio.sleep(30 * 60)
async def FiveMinUpdaters(): async def FiveMinUpdaters():
while True: while True:
@ -43,12 +46,13 @@ async def HourUpdaters():
l.debug("Sleeping for an hour...") l.debug("Sleeping for an hour...")
await asyncio.sleep(60 * 60) await asyncio.sleep(60 * 60)
async def main(): loop = asyncio.get_event_loop()
# Create loops alertTask = loop.create_task(grabAlertsLoop())
asyncio.create_task(grabAlertsLoop()) CCtask = loop.create_task(FiveMinUpdaters())
asyncio.create_task(FiveMinUpdaters()) ForecastsTask = loop.create_task(HourUpdaters())
asyncio.create_task(HourUpdaters())
asyncio.create_task(RadarProcessingLoop())
if __name__ == "__main__": try:
asyncio.run(main()) loop.run_until_complete(alertTask)
loop.run_until_complete(CCtask)
loop.run_until_complete(ForecastsTask)
except asyncio.CancelledError: pass