Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Python: Python

Unimport statement

 

 

Python python RSS feed   Index | Next | Previous | View Threaded


wxPythoner at gmail

May 11, 2008, 1:02 AM

Post #1 of 3 (46 views)
Permalink
Unimport statement

We should have that statement, so that problems, expressed in
http://groups.google.com/group/comp.lang.python/browse_thread/thread/3bda1fc4895ec886/bc5fe40cfbd10124?lnk=raot#bc5fe40cfbd10124,
would not occur.
--
http://mail.python.org/mailman/listinfo/python-list


regnarg at seznam

May 11, 2008, 1:13 AM

Post #2 of 3 (41 views)
Permalink
Re: Unimport statement [In reply to]

The main problem are references to objects within a module, because
we can NEVER be sure there aren't any, even though we cleaned up
everything, that's just a consequence of Python nature. We can keep
the old objects referenced and it would make an equivalent to the
reload() builting, just without loading the module, in effect the
same as removing it from sys.modules and deleting imported references.
I do not see any possibe clean way to unload a module...

On Ne, kvÄ› 11, 2008 at 10:02:15 +0200, wxPythoner[at]gmail.com wrote:
> We should have that statement, so that problems, expressed in
> http://groups.google.com/group/comp.lang.python/browse_thread/thread/3bda1fc4895ec886/bc5fe40cfbd10124?lnk=raot#bc5fe40cfbd10124,
> would not occur.


--
http://mail.python.org/mailman/listinfo/python-list


rhamph at gmail

May 11, 2008, 9:21 AM

Post #3 of 3 (37 views)
Permalink
Re: Unimport statement [In reply to]

On May 11, 2:13 am, Filip ©tědronský <regn...@seznam.cz> wrote:
> The main problem are references to objects within a module, because
> we can NEVER be sure there aren't any, even though we cleaned up
> everything, that's just a consequence of Python nature. We can keep
> the old objects referenced and it would make an equivalent to the
> reload() builting, just without loading the module, in effect the
> same as removing it from sys.modules and deleting imported references.
> I do not see any possibe clean way to unload a module...

With the finalizer changes in safethread I think I could pull it off.
Put the module in a cycle, add a weakref to it, remove it from
sys.modules, then run a full collection. If the weakref clears,
success. If the weakref doesn't clear, module isn't deleted, readd it
to sys.modules, clean up, and raise an exception. It won't always
remove the module, but it will do so safely and atomically.

The finalizer changes are necessary as current Python will run __del__
and weakref callbacks as it deletes the module. It may get
resurrected, get only half done, etc. Nasty stuff.
--
http://mail.python.org/mailman/listinfo/python-list

Python python RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact lists@gossamer-threads.com
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.