How to use threading.Condition to wait for several Flask-APScheduler one-off jobs to complete execution in your Python 3 application
When we run jobs as discussed in that post, jobs are ran once by the underlying ApScheduler instance. In addition, our Flask endpoint return the HTTP response back to the HTTP client as soon as the jobs are scheduled.
If we do not want the HTTP client to know the outcome of the jobs within that HTTP call, then we are good. But what if we want to include any errors that the jobs encounter in the same HTTP response?
In such a situation, we will need a mechanism to wait for the one-off jobs to complete execution before returning that response.
Given that in mind, this post shows how we can use
threading.Condition to wait for several
Flask-APScheduler one-off jobs to complete execution.