python - Why are you never supposed to reload modules? -


this question has answer here:

in "modules , packages: live , let die!", page 28 (see the video), it's said that:

you can force-reload module, you're never supposed it.

can explain why not supposed reload modules in python?

reloading explained in detail here: how unload (reload) python module?

tl;rd

there valid use cases reload, django development server. in general, reloading modules has many caveats practical.

two largest concerns are:

  1. to unload old objects, must make sure no other module or object keeps references them (which impossible). if fail here, may hard-to-trace memory leak or unexpected behavior.

  2. there no general way reload module c extensions. may reload safely; may seem reload safely, leak, , may crash interpreter or produce weird bugs.


Comments

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -