[Python-Dev] Fix import errors to have data (original) (raw)

Christian Tismer tismer at stackless.com
Tue Aug 3 04:21:14 CEST 2004


Greg Ewing wrote:

Maybe it could be as simple as saving a snapshot of sys.modules whenever importing of a module is begun, and if execution of its body doesn't complete, restoring the snapshot?

This is exactly what I thought of. It seems to be correct, also with nested imports, since this is a stack-like structure of undoable things. What happens in the presence of threads, though?

To my memory, imports in the presense of threads always have been a nightmare. My advice always goues this way: If you must have threads, make sure to import everything through the main thread, before starting new ones.

If you then still have problems, well, I have a different solution, which is also more efficient,... ... but this is another story. Off topic.

-- Christian Tismer :^) <mailto:tismer at stackless.com> Mission Impossible 5oftware : Have a break! Take a ride on Python's Johannes-Niemeyer-Weg 9a : Starship http://starship.python.net/ 14109 Berlin : PGP key -> http://wwwkeys.pgp.net/ work +49 30 89 09 53 34 home +49 30 802 86 56 mobile +49 173 24 18 776 PGP 0x57F3BF04 9064 F4E1 D754 C2FF 1619 305B C09C 5A3B 57F3 BF04 whom do you want to sponsor today? http://www.stackless.com/



More information about the Python-Dev mailing list