Provide an option to disable checks in threads
ron8mcr opened this issue · comments
Hello, thanks for a great app!
We used django-health-check
for a while with no problems.
But recently we faced increased RAM usage.
After digging out we've reported issue to boto/boto3#3614 and were advised to reuse boto3.Session
object as much as possible. I've noticed 2 possible improvements for django-health-check
:
- #359
- Provide ability to disable threading when using health checks (this issue). Currently each check run in thread, and some storages will make extra actions because of that.
What do you think about extending HEALTH_CHECK
setting with ability to run checks in single thread?
Agree that this would be helpful! We've recently run in to boto/boto3#801
Our use case is that we are using django-health-check to ensure the app can connect to and has permissions for various aws services. These fail intermittently, and it took some spelunking into DHC internals to identify that it executes checks in threads.
A configuration option to add the ability to run checks without spawning threads would be most helpful. Thanks!
Maybe also having a "cleanup" method in BaseHealthCheckBackend
which is called in the finally clause of BaseHealthCheckBackend.run_check
method would be a good idea to address to this problem (since there may be elements which needs an explicit cleanup when using threads).
I'm interested in this too.
Actually, either disabling threads or passing the context would work in my use case.
To quote PEP-567:
executor = ThreadPoolExecutor()
current_context = contextvars.copy_context()
executor.submit(current_context.run, some_function)