1
0
mirror of https://github.com/fHDHR/fHDHR_NextPVR.git synced 2025-12-06 11:36:59 -05:00

Sleep to make sure Flask is ready for startup tasks

This commit is contained in:
deathbybandaid 2020-12-16 08:39:42 -05:00
parent d47ecee009
commit 0cc13306ab

View File

@ -52,13 +52,6 @@ def run(settings, logger, db, script_dir, fHDHR_web, origin, alternative_epg):
if settings.dict["main"]["thread_method"] in ["multiprocessing", "threading"]:
fhdhr_web.start()
# Perform some actions now that HTTP Server is running, but don't wait for response
# Hit EPG Update API URL without waiting
try:
fhdhr.web.session.get("%s/api/startup_tasks" % (fhdhr.api.base))
except fhdhr.web.exceptions.ReadTimeout:
pass
if settings.dict["fhdhr"]["discovery_address"]:
fhdhr.logger.info("SSDP Server Starting")
if settings.dict["main"]["thread_method"] in ["multiprocessing"]:
@ -69,7 +62,7 @@ def run(settings, logger, db, script_dir, fHDHR_web, origin, alternative_epg):
fhdhr_ssdp.start()
if settings.dict["epg"]["method"]:
fhdhr.logger.info("EPG Update Starting")
fhdhr.logger.info("EPG Update Thread Starting")
if settings.dict["main"]["thread_method"] in ["multiprocessing"]:
fhdhr_epg = multiprocessing.Process(target=fhdhr.device.epg.run)
elif settings.dict["main"]["thread_method"] in ["threading"]:
@ -77,6 +70,18 @@ def run(settings, logger, db, script_dir, fHDHR_web, origin, alternative_epg):
if settings.dict["main"]["thread_method"] in ["multiprocessing", "threading"]:
fhdhr_epg.start()
# Perform some actions now that HTTP Server is running, but don't wait for response
# Hit EPG Update API URL without waiting
fhdhr.logger.info("Waiting 3 seconds to send startup tasks trigger.")
time.sleep(3)
try:
fhdhr.web.session.get("%s/api/startup_tasks" % (fhdhr.api.base))
except fhdhr.web.exceptions.ReadTimeout:
pass
except fhdhr.web.exceptions.ConnectionError as e:
fhdhr.logger.warning("Startup tasks failed: %s" % e)
pass
# wait forever
while True:
time.sleep(3600)