Skip to content
Advertisement

Tag: reload

How do I unload (reload) a Python module?

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? Answer You can reload a module when it has already been imported by using importlib.reload(): In Python 2, reload was a builtin. In Python 3, it was moved to the imp module. In

Advertisement