1. Ease the elegant exiting procedure by providing a singleton access pattern. Now the exiting procedure can easily call the exit_non_block method to notify the executors to start exiting worker processes. If the worker processes not exit after a timeout, the mindinsight stop still can kill these processes.
2. Build a framework for managing computing resources used by different businesses. Different businesses can now call the get_executor() API to get their process pool to execute compute heavy tasks outside the mindinsight guinicorn worker process, which will make the restful api respond more quickly.
If the env or gunicorn has some error, there will not be any error in console
or error log file when we set the subprocss stdout to devnull.
So I set it to None it will inhert its parent process stdout.
When gunicorn cause error, it will show error in console.
Main features:
1. Use the ComputingResourceManager to manage all computing workers.
2. Ensure fair worker number between summary directories at first. So every summary directories in cache will be loaded simultaneously.
3. When a summary directory is loaded, it's worker will be released, and other unfinished summary directories can use the released workers to speed up. This way we solved the slow worker problem.
Code changes:
1. Added computing_resource_mgr.py
2. Passed ComputingResourceManager instances instead of workers_count
3. Simplified the _load_single_fine() function a bit.
Use the AST replaces the importlib/inspect modules to analyze and modify network definition script.
The importlib/inspect must load python script to analyze, but AST analysis is static code analysis and is very secure.