revsys / django-health-check

a pluggable app that runs a full check on the deployment, using a number of plugins to check e.g. database, queue server, celery processes, etc.

Home Page:https://readthedocs.org/projects/django-health-check/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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:

  1. #359
  2. 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!

commented

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)