I know about app.after_request and app.teardown_request, but is there any way I can run a logging command after the response has been flushed to the client.. ie. in a way that doesn't impact the client's performance?
I was tempted to say the request_finished signal would work, but testing it out now, it does wait until the listener is finished before returning to the user.
So I think that leaves you with implementing a task queue- Flask has some documentation on getting Celery based background tasks working. So when you reach your slow logging command, you'd instead just add the task to the Celery queue, finish your response to the user, then let a Celery worker take care of the task as it's able.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With