How do I unload (reload) a Python module?

后端 未结 20 2355
轮回少年
轮回少年 2020-11-21 05:20

I have a long-running Python server and would like to be able to upgrade a service without restarting the server. What\'s the best way do do this?

if foo.py          


        
20条回答
  •  离开以前
    2020-11-21 05:39

    Those who are using python 3 and reload from importlib.

    If you have problems like it seems that module doesn't reload... That is because it needs some time to recompile pyc (up to 60 sec).I writing this hint just that you know if you have experienced this kind of problem.

提交回复
热议问题