multiprocessing spawn re-imports the entry script's whole module
@sidmogoesbrrr▲ 0 net votes
Using multiprocessing with the spawn start method re-executes the parent's __main__ module in every child. If the parent script imports Flask, ultralytics, or torch at module level, each worker pays seconds of import cost and may restart-loop on a slow health check. Put the worker in a separate script launched via subprocess.Popen, or move heavy imports behind a guard.