Skip to content

Commit

Permalink
Threadterminationbug (#28)
Browse files Browse the repository at this point in the history
* Fix premature thread termination bug

* Change where we wait
  • Loading branch information
andresp authored Oct 29, 2023
1 parent 51b957f commit f56c94a
Showing 1 changed file with 21 additions and 16 deletions.
37 changes: 21 additions & 16 deletions src/docsismodem/retriever.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,20 @@ def runDaemon():
consoleLogger.info("Running as daemon")
schedule.every(runEveryMinutes).minutes.do(jobRunner.collectionJob)

while 1:
schedule.run_pending()
time.sleep(1)

if enableHealthProbe is True:
while 1:
schedule.run_pending()
time.sleep(1)

if runAsDaemon:
runnerThread = threading.Thread(target=runDaemon, daemon=True)
runnerThread.start()
create_flask_app(jobRunner)
if enableHealthProbe is True:
create_flask_app(jobRunner)
else:
while 1:
schedule.run_pending()
time.sleep(1)
else:
consoleLogger.info("One-time execution")
jobRunner.collectionJob()
Expand All @@ -60,20 +66,19 @@ def runDaemon():

def create_flask_app(runner):

if enableHealthProbe is True:
app = Flask(__name__)
app.register_blueprint(healthz, url_prefix="/healthz")
app = Flask(__name__)
app.register_blueprint(healthz, url_prefix="/healthz")

probe = Probe(runner, runEveryMinutes)
probe = Probe(runner, runEveryMinutes)

app.config.update(
HEALTHZ = {
"live": probe.liveness,
"ready": lambda: None,
}
)
app.config.update(
HEALTHZ = {
"live": probe.liveness,
"ready": lambda: None,
}
)

app.run(host='0.0.0.0', port=80, debug=False, use_reloader=False)
app.run(host='0.0.0.0', port=80, debug=False, use_reloader=False)

class CustomTimestampFilter(logging.Filter):
def filter(self, record):
Expand Down

0 comments on commit f56c94a

Please sign in to comment.