python - Why are you never supposed to reload modules? -
this question has answer here:
- how unload (reload) python module? 12 answers
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:
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.
there no general way reload module c extensions. may reload safely; may seem reload safely, leak, , may crash interpreter or produce weird bugs.
Comments
Post a Comment